Skip to content

Commit a09d212

Browse files
committed
Condense conversion
1 parent 2c7d373 commit a09d212

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

CPAC/nuisance/utils/compcor.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,13 @@ def TR_string_to_float(tr):
198198
raise TypeError(f'Improper type for TR_string_to_float ({tr}).')
199199

200200
tr_str = tr.replace(' ', '')
201-
factor = 1.
202-
203-
if tr_str.endswith('ms'):
204-
tr_str = tr_str[:-2]
205-
factor = 0.001
206-
elif tr.endswith('s'):
207-
tr_str = tr_str[:-1]
208201

209202
try:
210-
tr_numeric = float(tr_str)
203+
if tr_str.endswith('ms'):
204+
tr_numeric = float(tr_str[:-2]) * 0.001
205+
elif tr.endswith('s'):
206+
tr_numeric = float(tr_str[:-1])
211207
except Exception as exc:
212208
raise ValueError(f'Can not convert TR string to float: "{tr}".') from exc
213209

214-
return tr_numeric * factor
210+
return tr_numeric

0 commit comments

Comments
 (0)