@@ -244,43 +244,44 @@ def get_trt(
244244
245245 return trt
246246
247- # npe = N voxels PE direction
248- pe_index = "ijk" .index (in_meta ["PhaseEncodingDirection" ][0 ])
249- npe = nb .load (in_file ).shape [pe_index ]
250-
251- # Use case 2: EES is defined
252- ees = in_meta .get ("EffectiveEchoSpacing" )
253- if ees :
254- # Effective echo spacing means that acceleration factors have been accounted for.
255- return ees * (npe - 1 )
256- elif use_estimate and "EstimatedEffectiveEchoSpacing" in in_meta :
257- return in_meta .get ("EstimatedEffectiveEchoSpacing" ) * (npe - 1 )
258-
259- try :
260- echospacing = in_meta ["EchoSpacing" ]
261- acc_factor = in_meta ["ParallelReductionFactorInPlane" ]
262- except KeyError :
263- pass
264- else :
265- # etl = effective train length
266- etl = npe // acc_factor
267- return echospacing * (etl - 1 )
268-
269- # Use case 3 (Philips scans)
270- try :
271- wfs = in_meta ["WaterFatShift" ]
272- epifactor = in_meta ["EPIFactor" ]
273- except KeyError :
274- pass
275- else :
276- wfs_hz = (
277- (in_meta .get ("ImagingFrequency" , 0 ) * 3.39941 )
278- or (in_meta .get ("MagneticFieldStrength" , 0 ) * 144.7383333 )
279- or None
280- )
281- if wfs_hz :
282- ees = wfs / (wfs_hz * (epifactor + 1 ))
247+ if "PhaseEncodingDirection" in in_meta :
248+ # npe = N voxels PE direction
249+ pe_index = "ijk" .index (in_meta ["PhaseEncodingDirection" ][0 ])
250+ npe = nb .load (in_file ).shape [pe_index ]
251+
252+ # Use case 2: EES is defined
253+ ees = in_meta .get ("EffectiveEchoSpacing" )
254+ if ees :
255+ # Effective echo spacing means that acceleration factors have been accounted for.
283256 return ees * (npe - 1 )
257+ elif use_estimate and "EstimatedEffectiveEchoSpacing" in in_meta :
258+ return in_meta .get ("EstimatedEffectiveEchoSpacing" ) * (npe - 1 )
259+
260+ try :
261+ echospacing = in_meta ["EchoSpacing" ]
262+ acc_factor = in_meta ["ParallelReductionFactorInPlane" ]
263+ except KeyError :
264+ pass
265+ else :
266+ # etl = effective train length
267+ etl = npe // acc_factor
268+ return echospacing * (etl - 1 )
269+
270+ # Use case 3 (Philips scans)
271+ try :
272+ wfs = in_meta ["WaterFatShift" ]
273+ epifactor = in_meta ["EPIFactor" ]
274+ except KeyError :
275+ pass
276+ else :
277+ wfs_hz = (
278+ (in_meta .get ("ImagingFrequency" , 0 ) * 3.39941 )
279+ or (in_meta .get ("MagneticFieldStrength" , 0 ) * 144.7383333 )
280+ or None
281+ )
282+ if wfs_hz :
283+ ees = wfs / (wfs_hz * (epifactor + 1 ))
284+ return ees * (npe - 1 )
284285
285286 if fallback :
286287 return fallback
0 commit comments