Skip to content

Commit 2c48e48

Browse files
authored
Write out confounds file even when no components are rejected (#123)
1 parent 8988dc8 commit 2c48e48

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/fmripost_aroma/interfaces/confounds.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ def _get_ica_confounds(mixing, aroma_features, skip_vols, newpath=None):
9292
# Return dummy list of ones if no noise components were found
9393
if motion_ics.size == 0:
9494
config.loggers.interface.warning('No noise components were classified')
95+
# Write out confounds with single column (intercept) so there's something generated.
96+
confounds_df = pd.DataFrame(
97+
columns=['intercept'],
98+
data=np.ones((padded_mixing_arr.shape[0], 1), dtype=int),
99+
)
100+
confounds_df.to_csv(aroma_confounds, sep='\t', index=False)
95101
return None, mixing_out
96102

97103
# return dummy lists of zeros if no signal components were found
@@ -176,6 +182,11 @@ def _run_interface(self, runtime):
176182
accepted_idx = metrics_df.loc[metrics_df['classification'] == 'accepted'].index.values
177183
rejected_components = mixing[:, rejected_idx]
178184
accepted_components = mixing[:, accepted_idx]
185+
if not rejected_components:
186+
print('No rejected components detected. Returning input data as "denoised".')
187+
self._results['denoised_file'] = bold_file
188+
return runtime
189+
179190
# Z-score all of the components
180191
rejected_components = stats.zscore(rejected_components, axis=0)
181192
accepted_components = stats.zscore(accepted_components, axis=0)

0 commit comments

Comments
 (0)