5858 2 1 1 1 0 2 1 16 62 64 64 0.00000 1.29035 4.28404e-003 1122 1951 -13.26 -0.00 -0.00 2.51 6.98 -10.53 6.000 2.000 0 1 0 2 3.750 3.750 30.00 0.00 0.00 0.00 0 90.00 0 0 0 39 0.0 1 1 8 0 0.000 0.000 0.000 1
5959 3 1 1 1 0 2 2 16 62 64 64 0.00000 1.29035 4.28404e-003 1137 1977 -13.26 -0.00 -0.00 2.51 14.77 -12.36 6.000 2.000 0 1 0 2 3.750 3.750 30.00 0.00 0.00 0.00 0 90.00 0 0 0 39 0.0 1 1 8 0 0.000 0.000 0.000 1
6060
61- ###########
6261Orientation
6362###########
6463
6867Anterior, inferior to Superior). The correspondence of the PAR file's axes to
6968RAS axes is:
7069
71- * ap = anterior -> posterior = negative A in RAS
72- * fh = foot -> head = S in RAS
73- * rl = right -> left = negative R in RAS
70+ * ap = anterior -> posterior = negative A in RAS = P
71+ * fh = foot -> head = S in RAS = S
72+ * rl = right -> left = negative R in RAS = L
73+
74+ We therefore call the PAR file's axis system "PSL" (Posterior, Superior, Left).
7475
7576The orientation of the PAR file axes corresponds to DICOM's LPS coordinate
7677system (right to Left, anterior to Posterior, inferior to Superior), but in a
7778different order.
7879
79- We call the PAR file's axis system "PSL" (Posterior, Superior, Left)
80-
81- #########
8280Data type
8381#########
8482
@@ -333,8 +331,8 @@ def _process_image_lines(image_lines, version):
333331def vol_numbers (slice_nos ):
334332 """ Calculate volume numbers inferred from slice numbers `slice_nos`
335333
336- The volume number for each slice is the number of times this slice has
337- occurred previously in the `slice_nos` sequence
334+ The volume number for each slice is the number of times this slice number
335+ has occurred previously in the `slice_nos` sequence
338336
339337 Parameters
340338 ----------
@@ -366,8 +364,8 @@ def vol_is_full(slice_nos, slice_max, slice_min=1):
366364 slice_max : int
367365 Highest slice number for a full slice set. Slice set will be
368366 ``range(slice_min, slice_max+1)``.
369- slice_min : int
370- Lowest slice number for full slice set.
367+ slice_min : int, optional
368+ Lowest slice number for full slice set. Default is 1.
371369
372370 Returns
373371 -------
@@ -379,7 +377,7 @@ def vol_is_full(slice_nos, slice_max, slice_min=1):
379377 Raises
380378 ------
381379 ValueError
382- if any `slice_nos` value is outside slice set.
380+ if any value in `slice_nos` is outside slice set indices .
383381 """
384382 slice_set = set (range (slice_min , slice_max + 1 ))
385383 if not slice_set .issuperset (slice_nos ):
@@ -465,7 +463,7 @@ def parse_PAR_header(fobj):
465463
466464def _data_from_rec (rec_fileobj , in_shape , dtype , slice_indices , out_shape ,
467465 scalings = None , mmap = True ):
468- """Get data from REC file
466+ """Load and return array data from REC file
469467
470468 Parameters
471469 ----------
@@ -485,10 +483,10 @@ def _data_from_rec(rec_fileobj, in_shape, dtype, slice_indices, out_shape,
485483 be broadcast to `out_shape`.
486484 mmap : {True, False, 'c', 'r', 'r+'}, optional
487485 `mmap` controls the use of numpy memory mapping for reading data. If
488- False, do not try numpy ``memmap`` for data array. If one of {'c', 'r',
489- 'r+'}, try numpy memmap with ``mode=mmap``. A `mmap` value of True
490- gives the same behavior as ``mmap='c'``. If `rec_fileobj` cannot be
491- memory-mapped, ignore `mmap` value and read array from file.
486+ False, do not try numpy ``memmap`` for data array. If one of {'c',
487+ 'r', 'r +'}, try numpy memmap with ``mode=mmap``. A `mmap` value of
488+ True gives the same behavior as ``mmap='c'``. If `rec_fileobj` cannot
489+ be memory-mapped, ignore `mmap` value and read array from file.
492490
493491 Returns
494492 -------
@@ -810,8 +808,8 @@ def _calc_zooms(self):
810808
811809 Notes
812810 -----
813- This routine called in ``__init__``, so may not be able to use
814- some attributes available in the fully initalized object.
811+ This routine gets called in ``__init__``, so may not be able to use
812+ some attributes available in the fully initialized object.
815813 """
816814 # slice orientation for the whole image series
817815 slice_gap = self ._get_unique_image_prop ('slice gap' )
@@ -917,8 +915,8 @@ def _calc_data_shape(self):
917915
918916 Notes
919917 -----
920- This routine called in ``__init__``, so may not be able to use
921- some attributes available in the fully initalized object.
918+ This routine gets called in ``__init__``, so may not be able to use
919+ some attributes available in the fully initialized object.
922920 """
923921 inplane_shape = tuple (self ._get_unique_image_prop ('recon resolution' ))
924922 shape = inplane_shape + (self ._get_n_slices (),)
@@ -945,13 +943,15 @@ def get_data_scaling(self, method="dv"):
945943 The PAR header contains two different scaling settings: 'dv' (value on
946944 console) and 'fp' (floating point value). Here is how they are defined:
947945
946+ DV = PV * RS + RI
947+ FP = DV / (RS * SS)
948+
949+ where:
950+
948951 PV: value in REC
949952 RS: rescale slope
950953 RI: rescale intercept
951954 SS: scale slope
952-
953- DV = PV * RS + RI
954- FP = DV / (RS * SS)
955955 """
956956 # These will be 3D or 4D
957957 scale_slope = self .image_defs ['scale slope' ]
@@ -987,14 +987,22 @@ def get_rec_shape(self):
987987 return inplane_shape + (len (self .image_defs ),)
988988
989989 def get_sorted_slice_indices (self ):
990- """Indices to sort (and maybe discard) slices in REC file
990+ """Return indices to sort (and maybe discard) slices in REC file.
991+
992+ Sorts by (fast to slow): slice number, volume number.
991993
992- Returns list for indexing into the last (third) dimension of the REC
993- data array, and (equivalently) the only dimension of
994- ``self.image_defs``.
994+ We calculate volume number by looking for repeating slice numbers (see
995+ :func:`vol_numbers`).
995996
996997 If the recording is truncated, the returned indices take care of
997- discarding any indices that are not meant to be used.
998+ discarding any slice indices from incomplete volumes.
999+
1000+ Returns
1001+ -------
1002+ slice_indices : list
1003+ List for indexing into the last (third) dimension of the REC data
1004+ array, and (equivalently) the only dimension of
1005+ ``self.image_defs``.
9981006 """
9991007 slice_nos = self .image_defs ['slice number' ]
10001008 is_full = vol_is_full (slice_nos , self .general_info ['max_slices' ])
@@ -1026,10 +1034,10 @@ def from_file_map(klass, file_map, mmap=True, permit_truncated=False,
10261034 mmap : {True, False, 'c', 'r'}, optional, keyword only
10271035 `mmap` controls the use of numpy memory mapping for reading image
10281036 array data. If False, do not try numpy ``memmap`` for data array.
1029- If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A `mmap`
1030- value of True gives the same behavior as ``mmap='c'``. If image
1031- data file cannot be memory-mapped, ignore `mmap` value and read
1032- array from file.
1037+ If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A
1038+ `mmap` value of True gives the same behavior as ``mmap='c'``. If
1039+ image data file cannot be memory-mapped, ignore `mmap` value and
1040+ read array from file.
10331041 permit_truncated : {False, True}, optional, keyword-only
10341042 If False, raise an error for an image where the header shows signs
10351043 that fewer slices / volumes were recorded than were expected.
@@ -1060,10 +1068,10 @@ def from_filename(klass, filename, mmap=True, permit_truncated=False,
10601068 mmap : {True, False, 'c', 'r'}, optional, keyword only
10611069 `mmap` controls the use of numpy memory mapping for reading image
10621070 array data. If False, do not try numpy ``memmap`` for data array.
1063- If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A `mmap`
1064- value of True gives the same behavior as ``mmap='c'``. If image
1065- data file cannot be memory-mapped, ignore `mmap` value and read
1066- array from file.
1071+ If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``. A
1072+ `mmap` value of True gives the same behavior as ``mmap='c'``. If
1073+ image data file cannot be memory-mapped, ignore `mmap` value and
1074+ read array from file.
10671075 permit_truncated : {False, True}, optional, keyword-only
10681076 If False, raise an error for an image where the header shows signs
10691077 that fewer slices / volumes were recorded than were expected.
0 commit comments