|
46 | 46 | The inability to store affines means that we have to guess what orientation the
|
47 | 47 | image has. Most Analyze images are stored on disk in (fastest-changing to
|
48 | 48 | slowest-changing) R->L, P->A and I->S order. That is, the first voxel is the
|
49 |
| -rightmost, most posterior and most inferior voxel location in the image, and the |
50 |
| -next voxel is one voxel towards the left of the image. |
| 49 | +rightmost, most posterior and most inferior voxel location in the image, and |
| 50 | +the next voxel is one voxel towards the left of the image. |
51 | 51 |
|
52 | 52 | Most people refer to this disk storage format as 'radiological', on the basis
|
53 | 53 | that, if you load up the data as an array ``img_arr`` where the first axis is
|
54 |
| -the fastest changing, then take a slice in the I->S axis - ``img_arr[:,:,10]`` - |
55 |
| -then the right part of the brain will be on the left of your displayed slice. |
| 54 | +the fastest changing, then take a slice in the I->S axis - ``img_arr[:,:,10]`` |
| 55 | +- then the right part of the brain will be on the left of your displayed slice. |
56 | 56 | Radiologists like looking at images where the left of the brain is on the right
|
57 | 57 | side of the image.
|
58 | 58 |
|
59 | 59 | Conversely, if the image has the voxels stored with the left voxels first -
|
60 | 60 | L->R, P->A, I->S, then this would be 'neurological' format. Neurologists like
|
61 | 61 | looking at images where the left side of the brain is on the left of the image.
|
62 | 62 |
|
63 |
| -When we are guessing at an affine for Analyze, this translates to the problem of |
64 |
| -whether the affine should consider proceeding within the data down an X line as |
65 |
| -being from left to right, or right to left. |
| 63 | +When we are guessing at an affine for Analyze, this translates to the problem |
| 64 | +of whether the affine should consider proceeding within the data down an X line |
| 65 | +as being from left to right, or right to left. |
66 | 66 |
|
67 | 67 | By default we assume that the image is stored in R->L format. We encode this
|
68 | 68 | choice in the ``default_x_flip`` flag that can be True or False. True means
|
|
153 | 153 | header_dtype = np.dtype(header_key_dtd + image_dimension_dtd +
|
154 | 154 | data_history_dtd)
|
155 | 155 |
|
156 |
| -_dtdefs = ( # code, conversion function, equivalent dtype, aliases |
| 156 | +_dtdefs = ( # code, conversion function, equivalent dtype, aliases |
157 | 157 | (0, 'none', np.void),
|
158 |
| - (1, 'binary', np.void), # 1 bit per voxel, needs thought |
| 158 | + (1, 'binary', np.void), # 1 bit per voxel, needs thought |
159 | 159 | (2, 'uint8', np.uint8),
|
160 | 160 | (4, 'int16', np.int16),
|
161 | 161 | (8, 'int32', np.int32),
|
162 | 162 | (16, 'float32', np.float32),
|
163 |
| - (32, 'complex64', np.complex64), # numpy complex format? |
| 163 | + (32, 'complex64', np.complex64), # numpy complex format? |
164 | 164 | (64, 'float64', np.float64),
|
165 |
| - (128, 'RGB', np.dtype([('R','u1'), |
166 |
| - ('G', 'u1'), |
167 |
| - ('B', 'u1')])), |
| 165 | + (128, 'RGB', np.dtype([('R', 'u1'), |
| 166 | + ('G', 'u1'), |
| 167 | + ('B', 'u1')])), |
168 | 168 | (255, 'all', np.void))
|
169 | 169 |
|
170 | 170 | # Make full code alias bank, including dtype column
|
@@ -343,7 +343,7 @@ def default_structarr(klass, endianness=None):
|
343 | 343 | hdr_data['dim'] = 1
|
344 | 344 | hdr_data['dim'][0] = 0
|
345 | 345 | hdr_data['pixdim'] = 1
|
346 |
| - hdr_data['datatype'] = 16 # float32 |
| 346 | + hdr_data['datatype'] = 16 # float32 |
347 | 347 | hdr_data['bitpix'] = 32
|
348 | 348 | return hdr_data
|
349 | 349 |
|
@@ -858,7 +858,7 @@ def _chk_bitpix(klass, hdr, fix=False):
|
858 | 858 | rep.problem_level = 10
|
859 | 859 | rep.problem_msg = 'bitpix does not match datatype'
|
860 | 860 | if fix:
|
861 |
| - hdr['bitpix'] = bitpix # inplace modification |
| 861 | + hdr['bitpix'] = bitpix # inplace modification |
862 | 862 | rep.fix_msg = 'setting bitpix to match datatype'
|
863 | 863 | return hdr, rep
|
864 | 864 |
|
@@ -897,7 +897,7 @@ class AnalyzeImage(SpatialImage):
|
897 | 897 | """ Class for basic Analyze format image
|
898 | 898 | """
|
899 | 899 | header_class = AnalyzeHeader
|
900 |
| - files_types = (('image','.img'), ('header','.hdr')) |
| 900 | + files_types = (('image', '.img'), ('header', '.hdr')) |
901 | 901 | _compressed_exts = ('.gz', '.bz2')
|
902 | 902 |
|
903 | 903 | ImageArrayProxy = ArrayProxy
|
@@ -931,10 +931,10 @@ def from_file_map(klass, file_map, mmap=True):
|
931 | 931 | mmap : {True, False, 'c', 'r'}, optional, keyword only
|
932 | 932 | `mmap` controls the use of numpy memory mapping for reading image
|
933 | 933 | array data. If False, do not try numpy ``memmap`` for data array.
|
934 |
| - If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A `mmap` |
935 |
| - value of True gives the same behavior as ``mmap='c'``. If image |
936 |
| - data file cannot be memory-mapped, ignore `mmap` value and read |
937 |
| - array from file. |
| 934 | + If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A |
| 935 | + `mmap` value of True gives the same behavior as ``mmap='c'``. If |
| 936 | + image data file cannot be memory-mapped, ignore `mmap` value and |
| 937 | + read array from file. |
938 | 938 |
|
939 | 939 | Returns
|
940 | 940 | -------
|
@@ -971,10 +971,10 @@ def from_filename(klass, filename, mmap=True):
|
971 | 971 | mmap : {True, False, 'c', 'r'}, optional, keyword only
|
972 | 972 | `mmap` controls the use of numpy memory mapping for reading image
|
973 | 973 | array data. If False, do not try numpy ``memmap`` for data array.
|
974 |
| - If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A `mmap` |
975 |
| - value of True gives the same behavior as ``mmap='c'``. If image |
976 |
| - data file cannot be memory-mapped, ignore `mmap` value and read |
977 |
| - array from file. |
| 974 | + If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A |
| 975 | + `mmap` value of True gives the same behavior as ``mmap='c'``. If |
| 976 | + image data file cannot be memory-mapped, ignore `mmap` value and |
| 977 | + read array from file. |
978 | 978 |
|
979 | 979 | Returns
|
980 | 980 | -------
|
@@ -1030,7 +1030,8 @@ def to_file_map(self, file_map=None):
|
1030 | 1030 | arr_writer = ArrayWriter(data, out_dtype, check_scaling=False)
|
1031 | 1031 | hdr_fh, img_fh = self._get_fileholders(file_map)
|
1032 | 1032 | # Check if hdr and img refer to same file; this can happen with odd
|
1033 |
| - # analyze images but most often this is because it's a single nifti file |
| 1033 | + # analyze images but most often this is because it's a single nifti |
| 1034 | + # file |
1034 | 1035 | hdr_img_same = hdr_fh.same_file_as(img_fh)
|
1035 | 1036 | hdrf = hdr_fh.get_prepare_fileobj(mode='wb')
|
1036 | 1037 | if hdr_img_same:
|
|
0 commit comments