Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions nipype/algorithms/modelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,6 @@
iflogger = logging.getLogger("nipype.interface")


def gcd(a, b):
"""
Return the greatest common divisor of two integers (uses Euclid's algorithm).

Examples
--------
>>> gcd(4, 5)
1
>>> gcd(4, 8)
4
>>> gcd(22, 55)
11

"""
while b > 0:
a, b = b, a % b
return a


def spm_hrf(RT, P=None, fMRI_T=16):
"""
python implementation of spm_hrf
Expand Down Expand Up @@ -799,9 +780,9 @@ def _gen_regress(self, i_onsets, i_durations, i_amplitudes, nscans):
matplotlib.use(config.get("execution", "matplotlib_backend"))
import matplotlib.pyplot as plt

TR = np.round(self.inputs.time_repetition * 1000) # in ms
TR = int(np.round(self.inputs.time_repetition * 1000)) # in ms
if self.inputs.time_acquisition:
TA = np.round(self.inputs.time_acquisition * 1000) # in ms
TA = int(np.round(self.inputs.time_acquisition * 1000)) # in ms
else:
TA = TR # in ms
nvol = self.inputs.volumes_in_cluster
Expand All @@ -813,10 +794,10 @@ def _gen_regress(self, i_onsets, i_durations, i_amplitudes, nscans):
if len(durations) == 1:
durations = durations * np.ones((len(i_onsets)))
onsets = np.round(np.array(i_onsets) * 1000)
dttemp = gcd(TA, gcd(SILENCE, TR))
dttemp = math.gcd(TA, math.gcd(SILENCE, TR))
if dt < dttemp:
if dttemp % dt != 0:
dt = float(gcd(dttemp, dt))
dt = float(math.gcd(dttemp, int(dt)))

if dt < 1:
raise Exception("Time multiple less than 1 ms")
Expand Down