@@ -184,27 +184,27 @@ def phase_encode(unwarp_dir, phase_one, phase_two, dwell_time_one=None,
184184 unwarp_dir = unwarp_dir .decode ()
185185
186186 if unwarp_dir in ["x" , "x-" , "-x" ,"i" ,"-i" ,"i-" ]:
187- if not ro_time_one or not ro_time_two :
188- if dwell_time_one and dwell_time_two :
189- dim = nibabel . load ( phase_one ). shape [ 0 ]
190- n_PE_steps = dim - 1
191- ro_time_one = np .round (dwell_time_one * n_PE_steps , 6 )
192- ro_time_two = np . round ( dwell_time_two * n_PE_steps , 6 )
193- else :
194- raise Exception ( "[!] No dwell time or total readout time "
195- "present for the acq-fMRI EPI field maps." )
196- ro_times = [ f"-1 0 0 { ro_time_one } " , f"1 0 0 { ro_time_two } " ]
187+ if dwell_time_one and dwell_time_two :
188+ dim = nibabel . load ( phase_one ). shape [ 0 ]
189+ n_PE_steps = dim - 1
190+ ro_time_one = np . round ( dwell_time_one * n_PE_steps , 6 )
191+ ro_time_two = np .round (dwell_time_two * n_PE_steps , 6 )
192+ elif ro_time_one and ro_time_two :
193+ ro_times = [ f"-1 0 0 { ro_time_one } " , f"1 0 0 { ro_time_two } " ]
194+ else :
195+ raise Exception ( "[!] No dwell time or total readout time "
196+ "present for the acq-fMRI EPI field maps." )
197197 elif unwarp_dir in ["y" , "y-" , "-y" ,"j" ,"-j" ,"j-" ]:
198- if not ro_time_one or not ro_time_two :
199- if dwell_time_one and dwell_time_two :
200- dim = nibabel . load ( phase_one ). shape [ 1 ]
201- n_PE_steps = dim - 1
202- ro_time_one = np .round (dwell_time_one * n_PE_steps , 6 )
203- ro_time_two = np . round ( dwell_time_two * n_PE_steps , 6 )
204- else :
205- raise Exception ( "[!] No dwell time or total readout time "
206- "present for the acq-fMRI EPI field maps." )
207- ro_times = [ f"0 -1 0 { ro_time_one } " , f"0 1 0 { ro_time_two } " ]
198+ if dwell_time_one and dwell_time_two :
199+ dim = nibabel . load ( phase_one ). shape [ 1 ]
200+ n_PE_steps = dim - 1
201+ ro_time_one = np . round ( dwell_time_one * n_PE_steps , 6 )
202+ ro_time_two = np .round (dwell_time_two * n_PE_steps , 6 )
203+ elif ro_time_one and ro_time_two :
204+ ro_times = [ f"0 -1 0 { ro_time_one } " , f"0 1 0 { ro_time_two } " ]
205+ else :
206+ raise Exception ( "[!] No dwell time or total readout time "
207+ "present for the acq-fMRI EPI field maps." )
208208 else :
209209 raise Exception (f"unwarp_dir={ unwarp_dir } is unsupported." )
210210
0 commit comments