Skip to content

Commit

Permalink
🐛 Fix header reading for bandpass filters
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy committed Sep 17, 2024
1 parent 96db8b0 commit 79ccfeb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions CPAC/nuisance/bandpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ def bandpass_voxels(realigned_file, regressor_file, bandpass_freqs,
img.to_filename(regressor_bandpassed_file)

else:
with open(regressor_file, 'r') as f:
header = []

# header wouldn't be longer than 5, right? I don't want to
# loop over the whole file
for i in range(5):
line = f.readline()
if line.startswith('#') or isinstance(line[0], str):
header = []
with open(regressor_file, "r") as _f:
# Each leading line that doesn't start with a number goes into the header
for line in _f.readlines():
try:
float(line.split()[0])
break
except ValueError:
header.append(line)

# usecols=[list]
regressor = np.loadtxt(regressor_file, skiprows=len(header))
Yc = regressor - np.tile(regressor.mean(0), (regressor.shape[0], 1))
Expand Down

0 comments on commit 79ccfeb

Please sign in to comment.