Skip to content

Commit

Permalink
generally handle all nans
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkent committed Dec 27, 2019
1 parent caa3035 commit 6131775
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/nibetaseries/interfaces/nistats.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,11 @@ def _select_confounds(confounds_file, selected_confounds):
contains all desired (processed) confounds.
"""
import pandas as pd
import numpy as np
confounds_df = pd.read_csv(confounds_file, sep='\t', na_values='n/a')

# fill the first value of FramewiseDisplacement with the mean.
if 'FramewiseDisplacement' in selected_confounds:
confounds_df['FramewiseDisplacement'] = confounds_df['FramewiseDisplacement'].fillna(
np.mean(confounds_df['FramewiseDisplacement']))
# fill all nans with zero?
for confound in selected_confounds:
confounds_df[confound] = confounds_df[confound].fillna(0)

desired_confounds = confounds_df[selected_confounds]
return desired_confounds

0 comments on commit 6131775

Please sign in to comment.