@@ -420,7 +420,7 @@ def _run_interface(self, runtime):
420
420
mask_images = self ._process_masks (mask_images , imgseries .get_data ())
421
421
422
422
TR = 0
423
- if self .inputs .high_pass_filter :
423
+ if self .inputs .pre_filter == 'cosine' :
424
424
if isdefined (self .inputs .repetition_time ):
425
425
TR = self .inputs .repetition_time
426
426
else :
@@ -965,27 +965,34 @@ def compute_noise_components(imgseries, mask_images, num_components,
965
965
966
966
imgseries: a nibabel img
967
967
mask_images: a list of nibabel images
968
- degree: order of polynomial used to remove trends from the timeseries
969
968
num_components: number of noise components to return
970
- high_pass_filter: high-pass-filter data with discrete cosine basis
971
- (run before polynomial detrend)
969
+ filter_type: type off filter to apply to time series before computing
970
+ noise components.
971
+ 'polynomial' - Legendre polynomial basis
972
+ 'cosine' - Discrete cosine (DCT) basis
973
+ False - None (mean-removal only)
974
+
975
+ Filter options:
976
+
977
+ degree: order of polynomial used to remove trends from the timeseries
978
+ period_cut: minimum period (in sec) for DCT high-pass filter
972
979
repetition_time: time (in sec) between volume acquisitions
973
980
974
981
returns:
975
982
976
983
components: a numpy array
977
- hpf_basis : a numpy array, if high_pass_filter is True, else None
984
+ basis : a numpy array containing the (non-constant) filter regressors
978
985
979
986
"""
980
987
components = None
981
- basis = None
988
+ basis = np . array ([])
982
989
for img in mask_images :
983
990
mask = img .get_data ().astype (np .bool )
984
991
if imgseries .shape [:3 ] != mask .shape :
985
- raise ValueError ('Inputs for CompCor, timeseries and mask, '
986
- ' do not have matching spatial dimensions '
987
- ' ({} and {}, respectively)' .format (
988
- imgseries .shape [:3 ], mask .shape ))
992
+ raise ValueError (
993
+ 'Inputs for CompCor, timeseries and mask, do not have '
994
+ 'matching spatial dimensions ({} and {}, respectively)' .format (
995
+ imgseries .shape [:3 ], mask .shape ))
989
996
990
997
voxel_timecourses = imgseries [mask , :]
991
998
@@ -1035,6 +1042,7 @@ def _compute_tSTD(M, x, axis=0):
1035
1042
# _cosine_drift and _full_rank copied from nipy/modalities/fmri/design_matrix
1036
1043
#
1037
1044
# Nipy release: 0.4.1
1045
+ # Modified for smooth integration in CompCor classes
1038
1046
1039
1047
def _cosine_drift (period_cut , frametimes ):
1040
1048
"""Create a cosine drift matrix with periods greater or equals to period_cut
@@ -1055,22 +1063,23 @@ def _cosine_drift(period_cut, frametimes):
1055
1063
"""
1056
1064
len_tim = len (frametimes )
1057
1065
n_times = np .arange (len_tim )
1058
- hfcut = 1. / period_cut # input parameter is the period
1066
+ hfcut = 1. / period_cut # input parameter is the period
1059
1067
1060
- dt = frametimes [1 ] - frametimes [0 ] # frametimes.max() should be (len_tim-1)*dt
1068
+ # frametimes.max() should be (len_tim-1)*dt
1069
+ dt = frametimes [1 ] - frametimes [0 ]
1070
+ # hfcut = 1/(2*dt) yields len_time
1061
1071
# If series is too short, return constant regressor
1062
- order = max (int (np .floor (2 * len_tim * hfcut * dt )), 1 ) # s.t. hfcut = 1/(2*dt) yields len_tim
1072
+ order = max (int (np .floor (2 * len_tim * hfcut * dt )), 1 )
1063
1073
cdrift = np .zeros ((len_tim , order ))
1064
1074
nfct = np .sqrt (2.0 / len_tim )
1065
1075
1066
1076
for k in range (1 , order ):
1067
- cdrift [:,k - 1 ] = nfct * np .cos ((np .pi / len_tim )* (n_times + .5 )* k )
1077
+ cdrift [:, k - 1 ] = nfct * np .cos ((np .pi / len_tim ) * (n_times + .5 ) * k )
1068
1078
1069
- cdrift [:,order - 1 ] = 1. # or 1./sqrt(len_tim) to normalize
1079
+ cdrift [:, order - 1 ] = 1. # or 1./sqrt(len_tim) to normalize
1070
1080
return cdrift
1071
1081
1072
1082
1073
-
1074
1083
def _full_rank (X , cmax = 1e15 ):
1075
1084
"""
1076
1085
This function possibly adds a scalar matrix to X
@@ -1091,7 +1100,7 @@ def _full_rank(X, cmax=1e15):
1091
1100
c = smax / smin
1092
1101
if c < cmax :
1093
1102
return X , c
1094
- warn ('Matrix is singular at working precision, regularizing...' )
1103
+ IFLOG . warn ('Matrix is singular at working precision, regularizing...' )
1095
1104
lda = (smax - cmax * smin ) / (cmax - 1 )
1096
1105
s = s + lda
1097
1106
X = np .dot (U , np .dot (np .diag (s ), V ))
0 commit comments