rapidtide 3.0.6__py3-none-any.whl → 3.0.7.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rapidtide/resample.py CHANGED
@@ -124,7 +124,17 @@ congridyvals["kernel"] = "kaiser"
124
124
  congridyvals["width"] = 3.0
125
125
 
126
126
 
127
- def congrid(xaxis, loc, val, width, kernel="kaiser", cyclic=True, debug=False):
127
+ def congrid(
128
+ xaxis,
129
+ loc,
130
+ val,
131
+ width,
132
+ kernel="kaiser",
133
+ cache=True,
134
+ cyclic=True,
135
+ debug=False,
136
+ onlykeynotices=True,
137
+ ):
128
138
  """
129
139
  Perform a convolution gridding operation with a Kaiser-Bessel or Gaussian kernel of width 'width'. Grid
130
140
  parameters are cached for performance.
@@ -164,10 +174,10 @@ def congrid(xaxis, loc, val, width, kernel="kaiser", cyclic=True, debug=False):
164
174
 
165
175
  if (congridyvals["kernel"] != kernel) or (congridyvals["width"] != width):
166
176
  if congridyvals["kernel"] != kernel:
167
- if debug:
177
+ if debug and not onlykeynotices:
168
178
  print(congridyvals["kernel"], "!=", kernel)
169
179
  if congridyvals["width"] != width:
170
- if debug:
180
+ if debug and not onlykeynotices:
171
181
  print(congridyvals["width"], "!=", width)
172
182
  if debug:
173
183
  print("(re)initializing congridyvals")
@@ -191,7 +201,7 @@ def congrid(xaxis, loc, val, width, kernel="kaiser", cyclic=True, debug=False):
191
201
 
192
202
  # find the closest grid point to the target location, calculate relative offsets from this point
193
203
  center = tide_util.valtoindex(xaxis, loc)
194
- offset = np.fmod(np.round((loc - xaxis[center]) / xstep, 3), 1.0) # will vary from -0.5 to 0.5
204
+ offset = np.fmod(np.round((loc - xaxis[center]) / xstep, 4), 1.0) # will vary from -0.5 to 0.5
195
205
  if cyclic:
196
206
  if center == len(xaxis) - 1 and offset > 0.5:
197
207
  center = 0
@@ -224,12 +234,13 @@ def congrid(xaxis, loc, val, width, kernel="kaiser", cyclic=True, debug=False):
224
234
  )
225
235
  + offset
226
236
  )
227
- congridyvals[offsetkey] = tide_fit.gauss_eval(xvals, np.array([1.0, 0.0, width]))
228
- yvals = congridyvals[offsetkey]
237
+ yvals = tide_fit.gauss_eval(xvals, np.array([1.0, 0.0, width]))
238
+ if cache:
239
+ congridyvals[offsetkey] = 1.0 * yvals
229
240
  startpt = int(center - widthinpts // 2)
230
241
  indices = range(startpt, startpt + widthinpts)
231
242
  indices = np.remainder(indices, len(xaxis))
232
- if debug:
243
+ if debug and not onlykeynotices:
233
244
  print("center, offset, indices, yvals", center, offset, indices, yvals)
234
245
  return val * yvals, yvals, indices
235
246
  else:
@@ -245,19 +256,18 @@ def congrid(xaxis, loc, val, width, kernel="kaiser", cyclic=True, debug=False):
245
256
  xvals = indices - center + offset
246
257
  if kernel == "gauss":
247
258
  sigma = optsigma[kernelindex]
248
- congridyvals[offsetkey] = tide_fit.gauss_eval(xvals, np.array([1.0, 0.0, sigma]))
259
+ yvals = tide_fit.gauss_eval(xvals, np.array([1.0, 0.0, sigma]))
249
260
  elif kernel == "kaiser":
250
261
  beta = optbeta[kernelindex]
251
- congridyvals[offsetkey] = tide_fit.kaiserbessel_eval(
252
- xvals, np.array([beta, width / 2.0])
253
- )
262
+ yvals = tide_fit.kaiserbessel_eval(xvals, np.array([beta, width / 2.0]))
254
263
  else:
255
264
  print("illegal kernel value in congrid - exiting")
256
265
  sys.exit()
257
- yvals = congridyvals[offsetkey]
258
- if debug:
266
+ if cache:
267
+ congridyvals[offsetkey] = 1.0 * yvals
268
+ if debug and not onlykeynotices:
259
269
  print("xvals, yvals", xvals, yvals)
260
- if debug:
270
+ if debug and not onlykeynotices:
261
271
  print("center, offset, indices, yvals", center, offset, indices, yvals)
262
272
  return val * yvals, yvals, indices
263
273
 
@@ -21,6 +21,7 @@ import matplotlib.pyplot as plt
21
21
  import numpy as np
22
22
 
23
23
  from rapidtide.resample import congrid
24
+ from rapidtide.happy_supportfuncs import preloadcongrid
24
25
  from rapidtide.tests.utils import mse
25
26
 
26
27
 
@@ -74,86 +75,74 @@ def test_congrid(debug=False, displayplots=False):
74
75
  weights = np.zeros((gridlen), dtype=float)
75
76
  griddeddata = np.zeros((gridlen), dtype=float)
76
77
 
77
- for gridkernel in kernellist:
78
- for congridbins in binslist:
79
- print("about to grid")
80
-
81
- # reinitialize grid outputs
82
- weights *= 0.0
83
- griddeddata *= 0.0
84
-
85
- for i in range(numsamples):
86
- thevals, theweights, theindices = congrid(
87
- gridaxis,
88
- testvals[i],
89
- funcvalue2(testvals[i], frequency=cycles),
90
- congridbins,
91
- kernel=gridkernel,
92
- debug=False,
93
- )
94
- for i in range(len(theindices)):
95
- weights[theindices[i]] += theweights[i]
96
- griddeddata[theindices[i]] += thevals[i]
97
-
98
- griddeddata = np.where(weights > 0.0, griddeddata / weights, 0.0)
99
-
100
- target = np.float64(gridaxis * 0.0)
101
- for i in range(len(gridaxis)):
102
- target[i] = funcvalue2(gridaxis[i], frequency=cycles)
103
-
104
- print("gridding done")
105
- print("debug:", debug)
106
-
107
- # plot if we are doing that
108
- if displayplots:
109
- offset = 0.0
110
- legend = []
111
- plt.plot(sourceaxis, timecoursein)
112
- legend.append("Original")
113
- # offset += 1.0
114
- plt.plot(gridaxis, target + offset)
115
- legend.append("Target")
116
- # offset += 1.0
117
- plt.plot(gridaxis, griddeddata + offset)
118
- legend.append("Gridded")
119
- plt.plot(gridaxis, weights)
120
- legend.append("Weights")
121
- plt.legend(legend)
122
- plt.show()
123
-
124
- # do the tests
125
- msethresh = 6.0e-2
126
- themse = mse(target, griddeddata)
127
- if debug:
128
- if themse >= msethresh:
129
- extra = "FAIL"
130
- else:
131
- extra = ""
132
- print(
133
- "mse for",
134
- cycles,
135
- "cycles:",
136
- gridkernel,
137
- str(congridbins),
138
- ":",
139
- themse,
140
- extra,
141
- )
142
- outputlines.append(
143
- " ".join(
144
- [
145
- "mse for",
146
- str(cycles),
147
- "cycles:",
148
- gridkernel,
149
- str(congridbins),
150
- ":",
151
- str(themse),
152
- ]
78
+ for prefill in [True, False]:
79
+ for gridkernel in kernellist:
80
+ for congridbins in binslist:
81
+ print("about to grid")
82
+
83
+ # reinitialize grid outputs
84
+ weights *= 0.0
85
+ griddeddata *= 0.0
86
+
87
+ if prefill:
88
+ preloadcongrid(
89
+ gridaxis, congridbins, gridkernel=gridkernel, cyclic=True, debug=False
90
+ )
91
+ for i in range(numsamples):
92
+ thevals, theweights, theindices = congrid(
93
+ gridaxis,
94
+ testvals[i],
95
+ funcvalue2(testvals[i], frequency=cycles),
96
+ congridbins,
97
+ kernel=gridkernel,
98
+ debug=False,
99
+ )
100
+ for i in range(len(theindices)):
101
+ weights[theindices[i]] += theweights[i]
102
+ griddeddata[theindices[i]] += thevals[i]
103
+
104
+ griddeddata = np.where(weights > 0.0, griddeddata / weights, 0.0)
105
+
106
+ target = np.float64(gridaxis * 0.0)
107
+ for i in range(len(gridaxis)):
108
+ target[i] = funcvalue2(gridaxis[i], frequency=cycles)
109
+
110
+ print("gridding done")
111
+ print("debug:", debug)
112
+
113
+ # plot if we are doing that
114
+ if displayplots:
115
+ offset = 0.0
116
+ legend = []
117
+ plt.plot(sourceaxis, timecoursein)
118
+ legend.append("Original")
119
+ # offset += 1.0
120
+ plt.plot(gridaxis, target + offset)
121
+ legend.append("Target")
122
+ # offset += 1.0
123
+ plt.plot(gridaxis, griddeddata + offset)
124
+ legend.append("Gridded")
125
+ plt.plot(gridaxis, weights)
126
+ legend.append("Weights")
127
+ plt.legend(legend)
128
+ plt.show()
129
+
130
+ # do the tests
131
+ msethresh = 6.0e-2
132
+ themse = mse(target, griddeddata)
133
+ if debug:
134
+ if themse >= msethresh:
135
+ extra = "FAIL"
136
+ else:
137
+ extra = ""
138
+ print(
139
+ f"mse for {cycles} cycles: {prefill=}, {gridkernel} {congridbins}: {themse} {extra}"
140
+ )
141
+ outputlines.append(
142
+ f"mse for {cycles} cycles: {prefill=}, {gridkernel} {congridbins}: {themse}"
153
143
  )
154
- )
155
- if not debug:
156
- assert themse < msethresh
144
+ if not debug:
145
+ assert themse < msethresh
157
146
  if debug:
158
147
  for theline in outputlines:
159
148
  print(theline)
rapidtide/voxelData.py CHANGED
@@ -100,6 +100,7 @@ class VoxelData:
100
100
  ysize = None
101
101
  numslices = None
102
102
  timepoints = None
103
+ dimensions = None
103
104
  realtimepoints = None
104
105
  xdim = None
105
106
  ydim = None
@@ -160,6 +161,10 @@ class VoxelData:
160
161
  self.xsize, self.ysize, self.numslices, self.timepoints = tide_io.parseniftidims(
161
162
  self.thedims
162
163
  )
164
+ if self.timepoints == 1:
165
+ self.dimensions = 3
166
+ else:
167
+ self.dimensions = 4
163
168
  self.numslicelocs = int(self.xsize) * int(self.ysize)
164
169
  self.numspatiallocs = int(self.xsize) * int(self.ysize) * int(self.numslices)
165
170
  self.cifti_hdr = None
@@ -283,15 +288,24 @@ class VoxelData:
283
288
  if not self.resident:
284
289
  self.load()
285
290
  if self.filetype == "nifti":
286
- return self.nim_data[:, :, :, self.validstart : self.validend + 1]
291
+ if self.dimensions == 4 or self.filetype == "cifti" or self.filetype == "text":
292
+ return self.nim_data[:, :, :, self.validstart : self.validend + 1]
293
+ else:
294
+ return self.nim_data[:, :, :]
287
295
  else:
288
296
  return self.nim_data[:, self.validstart : self.validend + 1]
289
297
 
290
298
  def byvoxel(self):
291
- return self.byvoltrimmed().reshape(self.numspatiallocs, -1)
299
+ if self.dimensions == 4 or self.filetype == "cifti" or self.filetype == "text":
300
+ return self.byvoltrimmed().reshape(self.numspatiallocs, -1)
301
+ else:
302
+ return self.byvoltrimmed().reshape(self.numspatiallocs)
292
303
 
293
304
  def byslice(self):
294
- return self.byvoltrimmed().reshape(self.numslicelocs, self.numslices, -1)
305
+ if self.dimensions == 4 or self.filetype == "cifti" or self.filetype == "text":
306
+ return self.byvoltrimmed().reshape(self.numslicelocs, self.numslices, -1)
307
+ else:
308
+ return self.byvoltrimmed().reshape(self.numslicelocs, self.numslices)
295
309
 
296
310
  def validdata(self):
297
311
  if self.validvoxels is None:
@@ -103,8 +103,9 @@ def cleanregressor(
103
103
  theCorrelator.setlimits(acmininpts, acmaxinpts)
104
104
  # theCorrelator.setlimits(lagmininpts, lagmaxinpts)
105
105
  print("check_autocorrelation:", acmininpts, acmaxinpts, lagmininpts, lagmaxinpts)
106
- thexcorr, accheckcorrscale, dummy = theCorrelator.run(
107
- resampref_y[osvalidsimcalcstart : osvalidsimcalcend + 1]
106
+ thexcorr, accheckcorrscale, theglobalmax = theCorrelator.run(
107
+ resampref_y[osvalidsimcalcstart : osvalidsimcalcend + 1],
108
+ trim=False,
108
109
  )
109
110
  theFitter.setcorrtimeaxis(accheckcorrscale)
110
111
  (
@@ -24,7 +24,7 @@ import warnings
24
24
  from pathlib import Path
25
25
 
26
26
  import numpy as np
27
- from tqdm import tqdm
27
+ from scipy.stats import pearsonr
28
28
 
29
29
  import rapidtide.correlate as tide_corr
30
30
  import rapidtide.filter as tide_filt
@@ -315,8 +315,10 @@ def happy_main(argparsingfunc):
315
315
  time,
316
316
  timings,
317
317
  LGR=None,
318
+ mpcode=args.mpdetrend,
318
319
  nprocs=args.nprocs,
319
320
  showprogressbar=args.showprogressbar,
321
+ debug=args.debug,
320
322
  )
321
323
  normdata_byslice = normdata.reshape((xsize * ysize, numslices, timepoints))
322
324
 
@@ -1243,7 +1245,9 @@ def happy_main(argparsingfunc):
1243
1245
  demeandata_byslice = demeandata.reshape((xsize * ysize, numslices, timepoints))
1244
1246
  means_byslice = means.reshape((xsize * ysize, numslices))
1245
1247
 
1246
- timings.append(["Phase projection to image started" + passstring, time.time(), None, None])
1248
+ timings.append(
1249
+ ["Phase projection to image prep started" + passstring, time.time(), None, None]
1250
+ )
1247
1251
  print("Starting phase projection")
1248
1252
  proctrs = range(timepoints) # proctrs is the list of all fmri trs to be projected
1249
1253
  procpoints = range(
@@ -1257,6 +1261,14 @@ def happy_main(argparsingfunc):
1257
1261
  proctrs = np.where(censortrs < 1)[0]
1258
1262
  procpoints = np.where(censorpoints < 1)[0]
1259
1263
 
1264
+ # preload congrid
1265
+ if args.preloadcongrid:
1266
+ print("Preloading congrid values...")
1267
+ happy_support.preloadcongrid(
1268
+ outphases, args.congridbins, gridkernel=args.gridkernel, cyclic=True, debug=False
1269
+ )
1270
+ print("done")
1271
+
1260
1272
  # do phase averaging
1261
1273
  app_bypoint, weights_bypoint = happy_support.cardiaccycleaverage(
1262
1274
  instantaneous_cardiacphase,
@@ -1266,6 +1278,7 @@ def happy_main(argparsingfunc):
1266
1278
  args.congridbins,
1267
1279
  args.gridkernel,
1268
1280
  args.centric,
1281
+ cache=args.congridcache,
1269
1282
  cyclic=True,
1270
1283
  )
1271
1284
  if thispass == numpasses - 1:
@@ -1358,9 +1371,53 @@ def happy_main(argparsingfunc):
1358
1371
  debug=args.debug,
1359
1372
  )
1360
1373
 
1374
+ timings.append(
1375
+ ["Phase projection to image prep ended" + passstring, time.time(), None, None]
1376
+ )
1361
1377
  if not args.verbose:
1362
1378
  print("Setting up for phase projection...")
1363
1379
 
1380
+ # make a vessel map using Wright's method
1381
+ if args.wrightiterations > 0:
1382
+ timings.append(
1383
+ [
1384
+ "Wright mask generation started" + passstring,
1385
+ time.time(),
1386
+ None,
1387
+ None,
1388
+ ]
1389
+ )
1390
+ wrightcorrs = happy_support.wrightmap(
1391
+ input_data,
1392
+ demeandata_byslice,
1393
+ rawapp_byslice,
1394
+ projmask_byslice,
1395
+ outphases,
1396
+ cardphasevals,
1397
+ proctrs,
1398
+ args.congridbins,
1399
+ args.gridkernel,
1400
+ args.destpoints,
1401
+ iterations=args.wrightiterations,
1402
+ nprocs=args.nprocs,
1403
+ verbose=False,
1404
+ debug=args.debug,
1405
+ )
1406
+
1407
+ theheader = input_data.copyheader(numtimepoints=1)
1408
+ wrightfilename = f"{outputroot}_desc-wrightcorrspass{thispass + 1}_map"
1409
+ tide_io.writedicttojson(bidsbasedict, wrightfilename + ".json")
1410
+ tide_io.savetonifti(wrightcorrs, theheader, wrightfilename)
1411
+ timings.append(
1412
+ [
1413
+ "Wright mask generation completed" + passstring,
1414
+ time.time(),
1415
+ None,
1416
+ None,
1417
+ ]
1418
+ )
1419
+
1420
+ timings.append(["Phase projection to image started" + passstring, time.time(), None, None])
1364
1421
  # make a lowpass filter for the projected data. Limit frequency to 3 cycles per 2pi (1/6th Fs)
1365
1422
  phaseFs = 1.0 / phasestep
1366
1423
  phaseFc = phaseFs / 6.0
@@ -593,6 +593,14 @@ def _get_parser():
593
593
  help="Will disable showing progress bars (helpful if stdout is going to a file). ",
594
594
  default=True,
595
595
  )
596
+ misc_opts.add_argument(
597
+ "--wrightiterations",
598
+ dest="wrightiterations",
599
+ action="store",
600
+ type=lambda x: pf.is_int(parser, x),
601
+ help="Number of iterations for calculating Wright map. Set to 0 to disable.",
602
+ default=0,
603
+ )
596
604
  pf.addtagopts(
597
605
  misc_opts,
598
606
  helptext="Additional key, value pairs to add to the info json file (useful for tracking analyses).",
@@ -692,6 +700,34 @@ def _get_parser():
692
700
  help="Decrease the number of intermediate output files. ",
693
701
  default=0,
694
702
  )
703
+ debug_opts.add_argument(
704
+ "--nompdetrend",
705
+ dest="mpdetrend",
706
+ action="store_false",
707
+ help="Disable multiproc detrending.",
708
+ default=True,
709
+ )
710
+ debug_opts.add_argument(
711
+ "--nompphaseproject",
712
+ dest="mpphaseproject",
713
+ action="store_false",
714
+ help="Disable multiproc phase projection.",
715
+ default=True,
716
+ )
717
+ debug_opts.add_argument(
718
+ "--noprefillcongrid",
719
+ dest="preloadcongrid",
720
+ action="store_false",
721
+ help="Don't prefill the congrid value cache.",
722
+ default=True,
723
+ )
724
+ debug_opts.add_argument(
725
+ "--nocongridcache",
726
+ dest="congridcache",
727
+ action="store_false",
728
+ help="Disable the congrid value cache completely.",
729
+ default=True,
730
+ )
695
731
 
696
732
  return parser
697
733
 
@@ -28,7 +28,6 @@ import numpy as np
28
28
  from scipy import ndimage
29
29
  from scipy.stats import rankdata
30
30
 
31
-
32
31
  import rapidtide.calccoherence as tide_calccoherence
33
32
  import rapidtide.calcnullsimfunc as tide_nullsimfunc
34
33
  import rapidtide.calcsimfunc as tide_calcsimfunc
@@ -392,6 +391,11 @@ def rapidtide_main(argparsingfunc):
392
391
  csfmask = anatomicmasks[3]
393
392
 
394
393
  # do spatial filtering if requested
394
+ if theinputdata.filetype == "nifti":
395
+ unfiltmeanvalue = np.mean(
396
+ theinputdata.byvoxel(),
397
+ axis=1,
398
+ )
395
399
  optiondict["gausssigma"] = theinputdata.smooth(
396
400
  optiondict["gausssigma"],
397
401
  brainmask=brainmask,
@@ -625,7 +629,6 @@ def rapidtide_main(argparsingfunc):
625
629
  )
626
630
  else:
627
631
  internaloffsetexcludemask_valid = None
628
-
629
632
  tide_util.logmem("after selecting valid voxels")
630
633
 
631
634
  # move fmri_data_valid into shared memory
@@ -738,7 +741,7 @@ def rapidtide_main(argparsingfunc):
738
741
  theheader["dim"][4] = 1
739
742
  theheader["pixdim"][4] = 1.0
740
743
  maplist = [
741
- (confoundr2, "confoundfilterR2", "map", None, "R2 of the motion/confound regression")
744
+ (confoundr2, "confoundfilterR2", "map", None, "R2 of the motion/confound regression"),
742
745
  ]
743
746
  tide_io.savemaplist(
744
747
  outputname,
@@ -2652,6 +2655,10 @@ def rapidtide_main(argparsingfunc):
2652
2655
  optiondict["currentstage"] = "presLFOfit"
2653
2656
  tide_io.writedicttojson(optiondict, f"{outputname}_desc-runoptions_info.json")
2654
2657
  if optiondict["dolinfitfilt"] or optiondict["docvrmap"] or optiondict["refinedelay"]:
2658
+ if optiondict["sLFOfiltmask"]:
2659
+ sLFOfiltmask = fitmask + 0.0
2660
+ else:
2661
+ sLFOfiltmask = fitmask * 0.0 + 1.0
2655
2662
  if optiondict["dolinfitfilt"]:
2656
2663
  if optiondict["refinedelay"]:
2657
2664
  TimingLGR.info("Setting up for delay refinement and sLFO filtering")
@@ -2831,7 +2838,7 @@ def rapidtide_main(argparsingfunc):
2831
2838
  validvoxels,
2832
2839
  initial_fmri_x,
2833
2840
  lagtimes,
2834
- fitmask,
2841
+ sLFOfiltmask,
2835
2842
  genlagtc,
2836
2843
  mode,
2837
2844
  outputname,
@@ -2927,7 +2934,7 @@ def rapidtide_main(argparsingfunc):
2927
2934
  namesuffix = "_desc-delayoffset_hist"
2928
2935
  if optiondict["dolinfitfilt"]:
2929
2936
  tide_stats.makeandsavehistogram(
2930
- delayoffset[np.where(fitmask > 0)],
2937
+ delayoffset[np.where(sLFOfiltmask > 0)],
2931
2938
  optiondict["histlen"],
2932
2939
  1,
2933
2940
  outputname + namesuffix,
@@ -2965,7 +2972,7 @@ def rapidtide_main(argparsingfunc):
2965
2972
  validvoxels,
2966
2973
  initial_fmri_x,
2967
2974
  lagstouse,
2968
- fitmask,
2975
+ sLFOfiltmask,
2969
2976
  genlagtc,
2970
2977
  mode,
2971
2978
  outputname,
@@ -3471,7 +3478,7 @@ def rapidtide_main(argparsingfunc):
3471
3478
  validvoxels,
3472
3479
  initial_fmri_x,
3473
3480
  lagstouse,
3474
- fitmask,
3481
+ sLFOfiltmask,
3475
3482
  genlagtc,
3476
3483
  mode,
3477
3484
  outputname,
@@ -3539,7 +3546,16 @@ def rapidtide_main(argparsingfunc):
3539
3546
  tide_util.cleanup_shm(fitNorm_shm)
3540
3547
 
3541
3548
  # write the 3D maps that don't need to be remapped
3549
+ if theinputdata.filetype != "nifti":
3550
+ unfiltmeanvalue = meanvalue
3542
3551
  maplist = [
3552
+ (
3553
+ unfiltmeanvalue,
3554
+ "unfiltmean",
3555
+ "map",
3556
+ None,
3557
+ "Voxelwise mean of fmri data before smoothing",
3558
+ ),
3543
3559
  (meanvalue, "mean", "map", None, "Voxelwise mean of fmri data"),
3544
3560
  (stddevvalue, "std", "map", None, "Voxelwise standard deviation of fmri data"),
3545
3561
  (covvalue, "CoV", "map", None, "Voxelwise coefficient of variation of fmri data"),
@@ -3564,6 +3580,7 @@ def rapidtide_main(argparsingfunc):
3564
3580
  cifti_hdr=theinputdata.cifti_hdr,
3565
3581
  )
3566
3582
  del meanvalue
3583
+ del unfiltmeanvalue
3567
3584
 
3568
3585
  if optiondict["numestreps"] > 0:
3569
3586
  masklist = []
@@ -1462,6 +1462,13 @@ def _get_parser():
1462
1462
  help=("Do regressor refinement on the final pass."),
1463
1463
  default=False,
1464
1464
  )
1465
+ experimental.add_argument(
1466
+ "--sLFOfiltmask",
1467
+ dest="sLFOfiltmask",
1468
+ action="store_true",
1469
+ help=("Limit sLFO filter to fit voxels."),
1470
+ default=False,
1471
+ )
1465
1472
  experimental.add_argument(
1466
1473
  "--territorymap",
1467
1474
  dest="territorymap",
@@ -219,6 +219,13 @@ def _get_parser():
219
219
  help=("Output lots of helpful information on a limited subset of operations."),
220
220
  default=False,
221
221
  )
222
+ parser.add_argument(
223
+ "--sLFOfiltmask",
224
+ dest="sLFOfiltmask",
225
+ action="store_true",
226
+ help=("Limit sLFO filter to fit voxels."),
227
+ default=False,
228
+ )
222
229
  experimental = parser.add_argument_group(
223
230
  "Experimental options (not fully tested, or not tested at all, may not work). Beware!"
224
231
  )
@@ -515,6 +522,10 @@ def retroregress(args):
515
522
  lagtimes_valid = lagtimes_spacebytime[validvoxels]
516
523
  corrmask_valid = corrmask_spacebytime[validvoxels]
517
524
  procmask_valid = procmask_spacebytime[validvoxels]
525
+ if args.sLFOfiltmask:
526
+ sLFOfiltmask_valid = corrmask_spacebytime[validvoxels] + 0.0
527
+ else:
528
+ sLFOfiltmask_valid = corrmask_spacebytime[validvoxels] * 0.0 + 1.0
518
529
  if args.debug:
519
530
  print(f"{fmri_data_valid.shape=}")
520
531
 
@@ -638,7 +649,7 @@ def retroregress(args):
638
649
  validvoxels,
639
650
  initial_fmri_x,
640
651
  lagtimes_valid,
641
- corrmask_valid,
652
+ sLFOfiltmask_valid,
642
653
  genlagtc,
643
654
  mode,
644
655
  outputname,
@@ -770,7 +781,7 @@ def retroregress(args):
770
781
  validvoxels,
771
782
  initial_fmri_x,
772
783
  lagstouse_valid,
773
- corrmask_valid,
784
+ sLFOfiltmask_valid,
774
785
  genlagtc,
775
786
  mode,
776
787
  outputname,
@@ -1032,6 +1043,13 @@ def retroregress(args):
1032
1043
  "corrfitREAD",
1033
1044
  "mask",
1034
1045
  None,
1046
+ "Correlation mask read for calculation",
1047
+ ),
1048
+ (
1049
+ sLFOfiltmask_valid,
1050
+ "corrfitUSED",
1051
+ "mask",
1052
+ None,
1035
1053
  "Correlation mask used for calculation",
1036
1054
  ),
1037
1055
  (
@@ -1255,7 +1273,7 @@ def retroregress(args):
1255
1273
  validvoxels,
1256
1274
  initial_fmri_x,
1257
1275
  lagstouse_valid,
1258
- corrmask_valid,
1276
+ sLFOfiltmask_valid,
1259
1277
  genlagtc,
1260
1278
  mode,
1261
1279
  outputname,