@@ -132,6 +132,9 @@ class T1:
132132 r2 : np.ndarray
133133 The R-Squared value of the fit, values close to 1 indicate a good
134134 fit, lower values indicate a poorer fit
135+ deformation_field : np.ndarray
136+ The deformation field generated by the model-driven registration
137+ process.
135138 shape : tuple
136139 The shape of the T1 map
137140 n_ti : int
@@ -266,7 +269,6 @@ def __init__(self, pixel_array, inversion_list, affine, tss=0, tss_axis=-2,
266269 assert (tss_axis < self .dimensions ), \
267270 'tss_axis must be less than the number of spatial dimensions'
268271 if (self .tss_axis != 2 ) & (self .mdr is True ):
269- print (self .tss_axis )
270272 raise ValueError ('Temporal slice spacing only supported '
271273 'along the z direction when using '
272274 'model-driven registration.' )
@@ -278,8 +280,10 @@ def __init__(self, pixel_array, inversion_list, affine, tss=0, tss_axis=-2,
278280 'using parameters=3.' )
279281
280282 if mdr :
283+ # The mdreg package can handle register each slice of an M2D
284+ # image separately provided the inversion times of each slice
285+ # are the same.
281286 if self .tss == 0 :
282- print ('Fitting with no TSS' )
283287 pixel_array , deform , _ , _ = mdreg .fit (
284288 self .pixel_array ,
285289 force_2d = True ,
@@ -309,6 +313,10 @@ def __init__(self, pixel_array, inversion_list, affine, tss=0, tss_axis=-2,
309313 pixel_array = np .zeros (self .pixel_array .shape )
310314 deform = np .zeros ((* self .pixel_array .shape [:3 ], 2 ,
311315 self .pixel_array .shape [3 ]))
316+
317+ # The following for loop is a workaround to allow a
318+ # different inversion list for each slice of data. Most of
319+ # the code comes from the mdreg.fit() function.
312320 for slice in range (self .shape [- 1 ]):
313321 print ('-----------------' )
314322 print ('Fitting slice ' + str (slice ).zfill (3 ))
@@ -344,7 +352,6 @@ def __init__(self, pixel_array, inversion_list, affine, tss=0, tss_axis=-2,
344352 # Changing the dimensions of the deformation field to a more
345353 # intuitive order.
346354 self .deformation_field = np .swapaxes (deform , - 2 , - 1 )
347-
348355 self .pixel_array = pixel_array
349356
350357 # Fit Data
@@ -680,6 +687,9 @@ def magnitude_correct(pixel_array):
680687
681688# Private wrapper for use by mdreg
682689def _t1_fit (pixel_array , inversion_list = None , affine = None , ** kwargs ):
690+ """
691+ Private wrapper for use by mdreg
692+ """
683693 map = T1 (pixel_array , inversion_list , affine , ** kwargs )
684694 if map .parameters == 2 :
685695 pars = np .stack ((map .t1_map , map .m0_map ), axis = - 1 )
0 commit comments