How to use the validators.BinaryHeaderAtt function in validators

To help you get started, we’ve selected a few validators examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
glmin = BinaryHeaderAtt('i', 144, 0)
    descrip = BinaryHeaderAtt('80s', 148, ' '*80)
    aux_file = BinaryHeaderAtt('24s', 228, ' '*24)
    qform_code = BinaryHeaderAtt('h', 252, 0)
    sform_code = BinaryHeaderAtt('h', 254, 0)
    quatern_b = BinaryHeaderAtt('f', 256, 0.0)
    quatern_c = BinaryHeaderAtt('f', 260, 0.)
    quatern_d = BinaryHeaderAtt('f', 264, 0.)
    qoffset_x = BinaryHeaderAtt('f', 268, 0.)
    qoffset_y = BinaryHeaderAtt('f', 272, 0.)
    qoffset_z = BinaryHeaderAtt('f', 276, 0.)
    srow_x = BinaryHeaderAtt('4f', 280, [0.,0.,1.,0.])
    srow_y = BinaryHeaderAtt('4f', 296, [0.,1.,0.,0.])
    srow_z = BinaryHeaderAtt('4f', 312, [1.,0.,0.,0.])
    intent_name = BinaryHeaderAtt('16s', 328, ' '*16)
    magic = BinaryHeaderAtt('4s', 344, 'ni1\0')

    extensions = traits.Trait(['.img', '.hdr', '.nii'], desc='Extensions supported by this format.')

    def __init__(self, hdrfilename, mode='r', create=False, datasource=DataSource(), **keywords):
        BinaryFile.__init__(self, **keywords)
        self.datasource = datasource
        ext = os.path.splitext(hdrfilename)[1]
        if ext not in ['.nii', '.hdr']:
            raise ValueError, 'NIFTI images need .hdr or .nii file specified.'

        self.filebase, self.fileext = os.path.splitext(hdrfilename)
        self.hdrfilename = hdrfilename
        
        # figure out machine byte order -- needed for reading binary data

        self.byteorder = sys.byteorder
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
bitpix = BinaryHeaderAtt('h', 72, 0)
    slice_start = BinaryHeaderAtt('h', 74, 0)
    pixdim = BinaryHeaderAtt('8f', 76, (1.,) + (0.,)*7)
    vox_offset = BinaryHeaderAtt('f', 108, 0)
    scl_slope = BinaryHeaderAtt('f', 112, 1.0)
    scl_inter = BinaryHeaderAtt('f', 116, 0.)
    slice_end = BinaryHeaderAtt('h', 120, 0)
    slice_code = BinaryHeaderAtt('b', 122, 0)
    xyzt_units = BinaryHeaderAtt('b', 123, 0)
    cal_max = BinaryHeaderAtt('f', 124, 0)
    cal_min = BinaryHeaderAtt('f', 128, 0)
    slice_duration = BinaryHeaderAtt('f', 132, 0)
    toffset = BinaryHeaderAtt('f', 136, 0)
    glmax = BinaryHeaderAtt('i', 140, 0)
    glmin = BinaryHeaderAtt('i', 144, 0)
    descrip = BinaryHeaderAtt('80s', 148, ' '*80)
    aux_file = BinaryHeaderAtt('24s', 228, ' '*24)
    qform_code = BinaryHeaderAtt('h', 252, 0)
    sform_code = BinaryHeaderAtt('h', 254, 0)
    quatern_b = BinaryHeaderAtt('f', 256, 0.0)
    quatern_c = BinaryHeaderAtt('f', 260, 0.)
    quatern_d = BinaryHeaderAtt('f', 264, 0.)
    qoffset_x = BinaryHeaderAtt('f', 268, 0.)
    qoffset_y = BinaryHeaderAtt('f', 272, 0.)
    qoffset_z = BinaryHeaderAtt('f', 276, 0.)
    srow_x = BinaryHeaderAtt('4f', 280, [0.,0.,1.,0.])
    srow_y = BinaryHeaderAtt('4f', 296, [0.,1.,0.,0.])
    srow_z = BinaryHeaderAtt('4f', 312, [1.,0.,0.,0.])
    intent_name = BinaryHeaderAtt('16s', 328, ' '*16)
    magic = BinaryHeaderAtt('4s', 344, 'ni1\0')

    extensions = traits.Trait(['.img', '.hdr', '.nii'], desc='Extensions supported by this format.')
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
slice_duration = BinaryHeaderAtt('f', 132, 0)
    toffset = BinaryHeaderAtt('f', 136, 0)
    glmax = BinaryHeaderAtt('i', 140, 0)
    glmin = BinaryHeaderAtt('i', 144, 0)
    descrip = BinaryHeaderAtt('80s', 148, ' '*80)
    aux_file = BinaryHeaderAtt('24s', 228, ' '*24)
    qform_code = BinaryHeaderAtt('h', 252, 0)
    sform_code = BinaryHeaderAtt('h', 254, 0)
    quatern_b = BinaryHeaderAtt('f', 256, 0.0)
    quatern_c = BinaryHeaderAtt('f', 260, 0.)
    quatern_d = BinaryHeaderAtt('f', 264, 0.)
    qoffset_x = BinaryHeaderAtt('f', 268, 0.)
    qoffset_y = BinaryHeaderAtt('f', 272, 0.)
    qoffset_z = BinaryHeaderAtt('f', 276, 0.)
    srow_x = BinaryHeaderAtt('4f', 280, [0.,0.,1.,0.])
    srow_y = BinaryHeaderAtt('4f', 296, [0.,1.,0.,0.])
    srow_z = BinaryHeaderAtt('4f', 312, [1.,0.,0.,0.])
    intent_name = BinaryHeaderAtt('16s', 328, ' '*16)
    magic = BinaryHeaderAtt('4s', 344, 'ni1\0')

    extensions = traits.Trait(['.img', '.hdr', '.nii'], desc='Extensions supported by this format.')

    def __init__(self, hdrfilename, mode='r', create=False, datasource=DataSource(), **keywords):
        BinaryFile.__init__(self, **keywords)
        self.datasource = datasource
        ext = os.path.splitext(hdrfilename)[1]
        if ext not in ['.nii', '.hdr']:
            raise ValueError, 'NIFTI images need .hdr or .nii file specified.'

        self.filebase, self.fileext = os.path.splitext(hdrfilename)
        self.hdrfilename = hdrfilename
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
slice_code = BinaryHeaderAtt('b', 122, 0)
    xyzt_units = BinaryHeaderAtt('b', 123, 0)
    cal_max = BinaryHeaderAtt('f', 124, 0)
    cal_min = BinaryHeaderAtt('f', 128, 0)
    slice_duration = BinaryHeaderAtt('f', 132, 0)
    toffset = BinaryHeaderAtt('f', 136, 0)
    glmax = BinaryHeaderAtt('i', 140, 0)
    glmin = BinaryHeaderAtt('i', 144, 0)
    descrip = BinaryHeaderAtt('80s', 148, ' '*80)
    aux_file = BinaryHeaderAtt('24s', 228, ' '*24)
    qform_code = BinaryHeaderAtt('h', 252, 0)
    sform_code = BinaryHeaderAtt('h', 254, 0)
    quatern_b = BinaryHeaderAtt('f', 256, 0.0)
    quatern_c = BinaryHeaderAtt('f', 260, 0.)
    quatern_d = BinaryHeaderAtt('f', 264, 0.)
    qoffset_x = BinaryHeaderAtt('f', 268, 0.)
    qoffset_y = BinaryHeaderAtt('f', 272, 0.)
    qoffset_z = BinaryHeaderAtt('f', 276, 0.)
    srow_x = BinaryHeaderAtt('4f', 280, [0.,0.,1.,0.])
    srow_y = BinaryHeaderAtt('4f', 296, [0.,1.,0.,0.])
    srow_z = BinaryHeaderAtt('4f', 312, [1.,0.,0.,0.])
    intent_name = BinaryHeaderAtt('16s', 328, ' '*16)
    magic = BinaryHeaderAtt('4s', 344, 'ni1\0')

    extensions = traits.Trait(['.img', '.hdr', '.nii'], desc='Extensions supported by this format.')

    def __init__(self, hdrfilename, mode='r', create=False, datasource=DataSource(), **keywords):
        BinaryFile.__init__(self, **keywords)
        self.datasource = datasource
        ext = os.path.splitext(hdrfilename)[1]
        if ext not in ['.nii', '.hdr']:
            raise ValueError, 'NIFTI images need .hdr or .nii file specified.'
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
slice_start = BinaryHeaderAtt('h', 74, 0)
    pixdim = BinaryHeaderAtt('8f', 76, (1.,) + (0.,)*7)
    vox_offset = BinaryHeaderAtt('f', 108, 0)
    scl_slope = BinaryHeaderAtt('f', 112, 1.0)
    scl_inter = BinaryHeaderAtt('f', 116, 0.)
    slice_end = BinaryHeaderAtt('h', 120, 0)
    slice_code = BinaryHeaderAtt('b', 122, 0)
    xyzt_units = BinaryHeaderAtt('b', 123, 0)
    cal_max = BinaryHeaderAtt('f', 124, 0)
    cal_min = BinaryHeaderAtt('f', 128, 0)
    slice_duration = BinaryHeaderAtt('f', 132, 0)
    toffset = BinaryHeaderAtt('f', 136, 0)
    glmax = BinaryHeaderAtt('i', 140, 0)
    glmin = BinaryHeaderAtt('i', 144, 0)
    descrip = BinaryHeaderAtt('80s', 148, ' '*80)
    aux_file = BinaryHeaderAtt('24s', 228, ' '*24)
    qform_code = BinaryHeaderAtt('h', 252, 0)
    sform_code = BinaryHeaderAtt('h', 254, 0)
    quatern_b = BinaryHeaderAtt('f', 256, 0.0)
    quatern_c = BinaryHeaderAtt('f', 260, 0.)
    quatern_d = BinaryHeaderAtt('f', 264, 0.)
    qoffset_x = BinaryHeaderAtt('f', 268, 0.)
    qoffset_y = BinaryHeaderAtt('f', 272, 0.)
    qoffset_z = BinaryHeaderAtt('f', 276, 0.)
    srow_x = BinaryHeaderAtt('4f', 280, [0.,0.,1.,0.])
    srow_y = BinaryHeaderAtt('4f', 296, [0.,1.,0.,0.])
    srow_z = BinaryHeaderAtt('4f', 312, [1.,0.,0.,0.])
    intent_name = BinaryHeaderAtt('16s', 328, ' '*16)
    magic = BinaryHeaderAtt('4s', 344, 'ni1\0')

    extensions = traits.Trait(['.img', '.hdr', '.nii'], desc='Extensions supported by this format.')
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
have the header to figure out what kind of file it is.
    """

    sizeof_hdr = BinaryHeaderAtt('i', 0, 348)
    data_type = BinaryHeaderAtt('10s', 4, ' '*10)
    db_name = BinaryHeaderAtt('18s', 14, ' '*18)
    extents = BinaryHeaderAtt('i', 32, 0)
    session_error = BinaryHeaderAtt('h', 36, 0)
    regular = BinaryHeaderAtt('s', 38, 'r')
    dim_info = BinaryHeaderAtt('b', 39, 0)
    dim = BinaryHeaderAtt('8h', 40, (4,1,1,1,1) + (0,)*3)
    intent_p1 = BinaryHeaderAtt('f', 56, 0.)
    intent_p2 = BinaryHeaderAtt('f', 60, 0.)
    intent_p3 = BinaryHeaderAtt('f', 64, 0.)
    intent_code = BinaryHeaderAtt('h', 68, 0)
    datatype = BinaryHeaderAtt('h', 70, 0)
    bitpix = BinaryHeaderAtt('h', 72, 0)
    slice_start = BinaryHeaderAtt('h', 74, 0)
    pixdim = BinaryHeaderAtt('8f', 76, (1.,) + (0.,)*7)
    vox_offset = BinaryHeaderAtt('f', 108, 0)
    scl_slope = BinaryHeaderAtt('f', 112, 1.0)
    scl_inter = BinaryHeaderAtt('f', 116, 0.)
    slice_end = BinaryHeaderAtt('h', 120, 0)
    slice_code = BinaryHeaderAtt('b', 122, 0)
    xyzt_units = BinaryHeaderAtt('b', 123, 0)
    cal_max = BinaryHeaderAtt('f', 124, 0)
    cal_min = BinaryHeaderAtt('f', 128, 0)
    slice_duration = BinaryHeaderAtt('f', 132, 0)
    toffset = BinaryHeaderAtt('f', 136, 0)
    glmax = BinaryHeaderAtt('i', 140, 0)
    glmin = BinaryHeaderAtt('i', 144, 0)
    descrip = BinaryHeaderAtt('80s', 148, ' '*80)
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
intent_p1 = BinaryHeaderAtt('f', 56, 0.)
    intent_p2 = BinaryHeaderAtt('f', 60, 0.)
    intent_p3 = BinaryHeaderAtt('f', 64, 0.)
    intent_code = BinaryHeaderAtt('h', 68, 0)
    datatype = BinaryHeaderAtt('h', 70, 0)
    bitpix = BinaryHeaderAtt('h', 72, 0)
    slice_start = BinaryHeaderAtt('h', 74, 0)
    pixdim = BinaryHeaderAtt('8f', 76, (1.,) + (0.,)*7)
    vox_offset = BinaryHeaderAtt('f', 108, 0)
    scl_slope = BinaryHeaderAtt('f', 112, 1.0)
    scl_inter = BinaryHeaderAtt('f', 116, 0.)
    slice_end = BinaryHeaderAtt('h', 120, 0)
    slice_code = BinaryHeaderAtt('b', 122, 0)
    xyzt_units = BinaryHeaderAtt('b', 123, 0)
    cal_max = BinaryHeaderAtt('f', 124, 0)
    cal_min = BinaryHeaderAtt('f', 128, 0)
    slice_duration = BinaryHeaderAtt('f', 132, 0)
    toffset = BinaryHeaderAtt('f', 136, 0)
    glmax = BinaryHeaderAtt('i', 140, 0)
    glmin = BinaryHeaderAtt('i', 144, 0)
    descrip = BinaryHeaderAtt('80s', 148, ' '*80)
    aux_file = BinaryHeaderAtt('24s', 228, ' '*24)
    qform_code = BinaryHeaderAtt('h', 252, 0)
    sform_code = BinaryHeaderAtt('h', 254, 0)
    quatern_b = BinaryHeaderAtt('f', 256, 0.0)
    quatern_c = BinaryHeaderAtt('f', 260, 0.)
    quatern_d = BinaryHeaderAtt('f', 264, 0.)
    qoffset_x = BinaryHeaderAtt('f', 268, 0.)
    qoffset_y = BinaryHeaderAtt('f', 272, 0.)
    qoffset_z = BinaryHeaderAtt('f', 276, 0.)
    srow_x = BinaryHeaderAtt('4f', 280, [0.,0.,1.,0.])
    srow_y = BinaryHeaderAtt('4f', 296, [0.,1.,0.,0.])
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
NIFTI-1 attributes must conform to their description in nifti1.h.

    You MUST pass the HEADER file as the filename, unlike ANALYZE where either will do.
    This may be a .hdr file ('ni1' case) or a .nii file ('n+1') case. The code needs to
    have the header to figure out what kind of file it is.
    """

    sizeof_hdr = BinaryHeaderAtt('i', 0, 348)
    data_type = BinaryHeaderAtt('10s', 4, ' '*10)
    db_name = BinaryHeaderAtt('18s', 14, ' '*18)
    extents = BinaryHeaderAtt('i', 32, 0)
    session_error = BinaryHeaderAtt('h', 36, 0)
    regular = BinaryHeaderAtt('s', 38, 'r')
    dim_info = BinaryHeaderAtt('b', 39, 0)
    dim = BinaryHeaderAtt('8h', 40, (4,1,1,1,1) + (0,)*3)
    intent_p1 = BinaryHeaderAtt('f', 56, 0.)
    intent_p2 = BinaryHeaderAtt('f', 60, 0.)
    intent_p3 = BinaryHeaderAtt('f', 64, 0.)
    intent_code = BinaryHeaderAtt('h', 68, 0)
    datatype = BinaryHeaderAtt('h', 70, 0)
    bitpix = BinaryHeaderAtt('h', 72, 0)
    slice_start = BinaryHeaderAtt('h', 74, 0)
    pixdim = BinaryHeaderAtt('8f', 76, (1.,) + (0.,)*7)
    vox_offset = BinaryHeaderAtt('f', 108, 0)
    scl_slope = BinaryHeaderAtt('f', 112, 1.0)
    scl_inter = BinaryHeaderAtt('f', 116, 0.)
    slice_end = BinaryHeaderAtt('h', 120, 0)
    slice_code = BinaryHeaderAtt('b', 122, 0)
    xyzt_units = BinaryHeaderAtt('b', 123, 0)
    cal_max = BinaryHeaderAtt('f', 124, 0)
    cal_min = BinaryHeaderAtt('f', 128, 0)
    slice_duration = BinaryHeaderAtt('f', 132, 0)
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
You MUST pass the HEADER file as the filename, unlike ANALYZE where either will do.
    This may be a .hdr file ('ni1' case) or a .nii file ('n+1') case. The code needs to
    have the header to figure out what kind of file it is.
    """

    sizeof_hdr = BinaryHeaderAtt('i', 0, 348)
    data_type = BinaryHeaderAtt('10s', 4, ' '*10)
    db_name = BinaryHeaderAtt('18s', 14, ' '*18)
    extents = BinaryHeaderAtt('i', 32, 0)
    session_error = BinaryHeaderAtt('h', 36, 0)
    regular = BinaryHeaderAtt('s', 38, 'r')
    dim_info = BinaryHeaderAtt('b', 39, 0)
    dim = BinaryHeaderAtt('8h', 40, (4,1,1,1,1) + (0,)*3)
    intent_p1 = BinaryHeaderAtt('f', 56, 0.)
    intent_p2 = BinaryHeaderAtt('f', 60, 0.)
    intent_p3 = BinaryHeaderAtt('f', 64, 0.)
    intent_code = BinaryHeaderAtt('h', 68, 0)
    datatype = BinaryHeaderAtt('h', 70, 0)
    bitpix = BinaryHeaderAtt('h', 72, 0)
    slice_start = BinaryHeaderAtt('h', 74, 0)
    pixdim = BinaryHeaderAtt('8f', 76, (1.,) + (0.,)*7)
    vox_offset = BinaryHeaderAtt('f', 108, 0)
    scl_slope = BinaryHeaderAtt('f', 112, 1.0)
    scl_inter = BinaryHeaderAtt('f', 116, 0.)
    slice_end = BinaryHeaderAtt('h', 120, 0)
    slice_code = BinaryHeaderAtt('b', 122, 0)
    xyzt_units = BinaryHeaderAtt('b', 123, 0)
    cal_max = BinaryHeaderAtt('f', 124, 0)
    cal_min = BinaryHeaderAtt('f', 128, 0)
    slice_duration = BinaryHeaderAtt('f', 132, 0)
    toffset = BinaryHeaderAtt('f', 136, 0)
    glmax = BinaryHeaderAtt('i', 140, 0)
github nipy / nipy / lib / neuroimaging / image / formats / nifti.py View on Github external
You MUST pass the HEADER file as the filename, unlike ANALYZE where either will do.
    This may be a .hdr file ('ni1' case) or a .nii file ('n+1') case. The code needs to
    have the header to figure out what kind of file it is.
    """

    sizeof_hdr = BinaryHeaderAtt('i', 0, 348)
    data_type = BinaryHeaderAtt('10s', 4, ' '*10)
    db_name = BinaryHeaderAtt('18s', 14, ' '*18)
    extents = BinaryHeaderAtt('i', 32, 0)
    session_error = BinaryHeaderAtt('h', 36, 0)
    regular = BinaryHeaderAtt('s', 38, 'r')
    dim_info = BinaryHeaderAtt('b', 39, 0)
    dim = BinaryHeaderAtt('8h', 40, (4,1,1,1,1) + (0,)*3)
    intent_p1 = BinaryHeaderAtt('f', 56, 0.)
    intent_p2 = BinaryHeaderAtt('f', 60, 0.)
    intent_p3 = BinaryHeaderAtt('f', 64, 0.)
    intent_code = BinaryHeaderAtt('h', 68, 0)
    datatype = BinaryHeaderAtt('h', 70, 0)
    bitpix = BinaryHeaderAtt('h', 72, 0)
    slice_start = BinaryHeaderAtt('h', 74, 0)
    pixdim = BinaryHeaderAtt('8f', 76, (1.,) + (0.,)*7)
    vox_offset = BinaryHeaderAtt('f', 108, 0)
    scl_slope = BinaryHeaderAtt('f', 112, 1.0)
    scl_inter = BinaryHeaderAtt('f', 116, 0.)
    slice_end = BinaryHeaderAtt('h', 120, 0)
    slice_code = BinaryHeaderAtt('b', 122, 0)
    xyzt_units = BinaryHeaderAtt('b', 123, 0)
    cal_max = BinaryHeaderAtt('f', 124, 0)
    cal_min = BinaryHeaderAtt('f', 128, 0)
    slice_duration = BinaryHeaderAtt('f', 132, 0)
    toffset = BinaryHeaderAtt('f', 136, 0)