rapidtide 3.0.2__py3-none-any.whl → 3.0.4__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.
@@ -29,6 +29,7 @@ import rapidtide.io as tide_io
29
29
  import rapidtide.util as tide_util
30
30
  import rapidtide.workflows.parser_funcs as pf
31
31
 
32
+
32
33
  # Create a sentinel.
33
34
  # from https://stackoverflow.com/questions/58594956/find-out-which-arguments-were-passed-explicitly-in-argparse
34
35
  class _Sentinel:
@@ -43,7 +44,7 @@ LGR = logging.getLogger(__name__)
43
44
  DEFAULT_SPATIALFILT = -1
44
45
  DEFAULT_HISTLEN = 101
45
46
  DEFAULT_DETREND_ORDER = 3
46
- DEFAULT_GLOBAL_PCACOMPONENTS = 0.8
47
+ DEFAULT_INITREGRESSOR_PCACOMPONENTS = 0.8
47
48
  DEFAULT_CORRMASK_THRESHPCT = 1.0
48
49
  DEFAULT_MUTUALINFO_SMOOTHINGTIME = 3.0
49
50
  DEFAULT_LAGMIN = -30.0
@@ -62,7 +63,7 @@ DEFAULT_MAXPASSES = 15
62
63
  DEFAULT_REFINE_TYPE = "pca"
63
64
  DEFAULT_INTERPTYPE = "univariate"
64
65
  DEFAULT_WINDOW_TYPE = "hamming"
65
- DEFAULT_GLOBALSIGNAL_METHOD = "sum"
66
+ DEFAULT_INITREGRESSOR_METHOD = "sum"
66
67
  DEFAULT_CORRWEIGHTING = "phat"
67
68
  DEFAULT_CORRTYPE = "linear"
68
69
  DEFAULT_SIMILARITYMETRIC = "correlation"
@@ -193,7 +194,7 @@ def _get_parser():
193
194
  )
194
195
  analysis_type.add_argument(
195
196
  "--globalpreselect",
196
- dest="globalpreselect",
197
+ dest="initregressorpreselect",
197
198
  action="store_true",
198
199
  help=(
199
200
  "Treat this run as an initial pass to locate good candidate voxels for global mean "
@@ -259,7 +260,7 @@ def _get_parser():
259
260
  "2) decide which voxels in which to calculate delays, "
260
261
  "3) refine the regressor at the end of each pass, 4) determine the zero time offset value, and 5) process "
261
262
  "to remove sLFO signal. "
262
- "Setting --globalmeaninclude, --refineinclude, --corrmaskinclude or --offsetinclude explicitly will "
263
+ "Setting --initregressorinclude, --corrmaskinclude, --refineinclude or --offsetinclude explicitly will "
263
264
  "override this for the given include mask."
264
265
  ),
265
266
  default=None,
@@ -272,9 +273,8 @@ def _get_parser():
272
273
  "This specifies a gray matter mask registered to the input functional data. "
273
274
  "If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
274
275
  "voxels with value > 0.1 are used. If this option is set, "
275
- "rapidtide will use voxels in the gray matter mask to 1) calculate the initial global mean regressor, "
276
- "and 2) for determining the zero time offset value. "
277
- "Setting --globalmeaninclude or --offsetinclude explicitly will override this for "
276
+ "rapidtide will use voxels in the gray matter mask to calculate the initial global mean regressor. "
277
+ "Setting --initregressorinclude explicitly will override this for "
278
278
  "the given include mask."
279
279
  ),
280
280
  default=None,
@@ -287,8 +287,21 @@ def _get_parser():
287
287
  "This specifies a white matter mask registered to the input functional data. "
288
288
  "If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
289
289
  "voxels with value > 0.1 are used. "
290
- "This currently isn't used for anything, but rapidtide will keep track of it and might use if for something "
291
- "in a later version."
290
+ "This will be used to calculate the white matter timecourse before running rapidtide, and after sLFO "
291
+ "filtering (if enabled)."
292
+ ),
293
+ default=None,
294
+ )
295
+ anatomy.add_argument(
296
+ "--csfmask",
297
+ dest="csfincludespec",
298
+ metavar="MASK[:VALSPEC]",
299
+ help=(
300
+ "This specifies a CSF mask registered to the input functional data. "
301
+ "If VALSPEC is given, only voxels in the mask with integral values listed in VALSPEC are used, otherwise "
302
+ "voxels with value > 0.1 are used. "
303
+ "This will be used to calculate the CSF timecourse before running rapidtide, and after sLFO "
304
+ "filtering (if enabled)."
292
305
  ),
293
306
  default=None,
294
307
  )
@@ -437,7 +450,7 @@ def _get_parser():
437
450
  )
438
451
  preproc.add_argument(
439
452
  "--globalmean",
440
- dest="useglobalref",
453
+ dest="useinitregressorref",
441
454
  action="store_true",
442
455
  help=(
443
456
  "Generate a global mean regressor and use that as the reference "
@@ -448,10 +461,10 @@ def _get_parser():
448
461
  )
449
462
  preproc.add_argument(
450
463
  "--globalmeaninclude",
451
- dest="globalmeanincludespec",
464
+ dest="initregressorincludespec",
452
465
  metavar="MASK[:VALSPEC]",
453
466
  help=(
454
- "Only use voxels in mask file NAME for global regressor "
467
+ "Only use voxels in mask file NAME for the initial regressor "
455
468
  "generation (if VALSPEC is given, only voxels "
456
469
  "with integral values listed in VALSPEC are used)."
457
470
  ),
@@ -459,10 +472,10 @@ def _get_parser():
459
472
  )
460
473
  preproc.add_argument(
461
474
  "--globalmeanexclude",
462
- dest="globalmeanexcludespec",
475
+ dest="initregressorexcludespec",
463
476
  metavar="MASK[:VALSPEC]",
464
477
  help=(
465
- "Do not use voxels in mask file NAME for global regressor "
478
+ "Do not use voxels in mask file NAME for the initial regressor "
466
479
  "generation (if VALSPEC is given, only voxels "
467
480
  "with integral values listed in VALSPEC are excluded)."
468
481
  ),
@@ -479,6 +492,16 @@ def _get_parser():
479
492
  ),
480
493
  default=None,
481
494
  )
495
+ preproc.add_argument(
496
+ "--motpowers",
497
+ dest="mot_power",
498
+ metavar="N",
499
+ type=lambda x: pf.is_int(parser, x, minval=1),
500
+ help=(
501
+ "Include powers of each motion regressor up to order N. Default is 1 (no expansion). "
502
+ ),
503
+ default=1,
504
+ )
482
505
  preproc.add_argument(
483
506
  "--nomotderiv",
484
507
  dest="mot_deriv",
@@ -530,32 +553,32 @@ def _get_parser():
530
553
  )
531
554
  preproc.add_argument(
532
555
  "--globalsignalmethod",
533
- dest="globalsignalmethod",
556
+ dest="initregressorsignalmethod",
534
557
  action="store",
535
558
  type=str,
536
559
  choices=["sum", "meanscale", "pca", "random"],
537
560
  help=(
538
- "The method for constructing the initial global signal regressor - straight summation, "
539
- "mean scaling each voxel prior to summation, MLE PCA of the voxels in the global signal mask, "
561
+ "The method for constructing the initial signal regressor - straight summation, "
562
+ "mean scaling each voxel prior to summation, MLE PCA of the voxels in the initial regressor mask, "
540
563
  "or initializing using random noise."
541
- f'Default is "{DEFAULT_GLOBALSIGNAL_METHOD}."'
564
+ f'Default is "{DEFAULT_INITREGRESSOR_METHOD}."'
542
565
  ),
543
- default=DEFAULT_GLOBALSIGNAL_METHOD,
566
+ default=DEFAULT_INITREGRESSOR_METHOD,
544
567
  )
545
568
  preproc.add_argument(
546
569
  "--globalpcacomponents",
547
- dest="globalpcacomponents",
570
+ dest="initregressorpcacomponents",
548
571
  action="store",
549
572
  type=float,
550
573
  metavar="VALUE",
551
574
  help=(
552
- "Number of PCA components used for estimating the global signal. If VALUE >= 1, will retain this"
575
+ "Number of PCA components used for estimating the initial regressor. If VALUE >= 1, will retain this"
553
576
  "many components. If "
554
577
  "0.0 < VALUE < 1.0, enough components will be retained to explain the fraction VALUE of the "
555
578
  "total variance. If VALUE is negative, the number of components will be to retain will be selected "
556
- f"automatically using the MLE method. Default is {DEFAULT_GLOBAL_PCACOMPONENTS}."
579
+ f"automatically using the MLE method. Default is {DEFAULT_INITREGRESSOR_PCACOMPONENTS}."
557
580
  ),
558
- default=DEFAULT_GLOBAL_PCACOMPONENTS,
581
+ default=DEFAULT_INITREGRESSOR_PCACOMPONENTS,
559
582
  )
560
583
  preproc.add_argument(
561
584
  "--slicetimes",
@@ -1270,7 +1293,7 @@ def _get_parser():
1270
1293
  "--saveintermediatemaps",
1271
1294
  dest="saveintermediatemaps",
1272
1295
  action="store_true",
1273
- help="Save lag times, strengths, widths, and mask for each pass.",
1296
+ help="Save lag times, strengths, widths, mask (and shiftedtcs, if they'd normally be saved) for each pass.",
1274
1297
  default=False,
1275
1298
  )
1276
1299
  output.add_argument(
@@ -1911,20 +1934,27 @@ def process_args(inputargs=None):
1911
1934
  else:
1912
1935
  args["inputfreq_nondefault"] = True
1913
1936
 
1914
- # mask processing
1915
- if args["corrmaskincludespec"] is not None:
1916
- (
1917
- args["corrmaskincludename"],
1918
- args["corrmaskincludevals"],
1919
- ) = tide_io.processnamespec(
1920
- args["corrmaskincludespec"],
1921
- "Including voxels where ",
1922
- "in correlation calculations.",
1923
- )
1924
- else:
1925
- args["corrmaskincludename"] = None
1926
-
1927
- # if brainmaskincludespec is set, set corrmaskinclude to it.
1937
+ # initial mask values from anatomical images (before any overrides)
1938
+ for key in [
1939
+ "corrmaskincludename",
1940
+ "corrmaskincludevals",
1941
+ "initregressorincludename",
1942
+ "initregressorincludevals",
1943
+ "initregressorexcludename",
1944
+ "initregressorexcludevals",
1945
+ "refineincludename",
1946
+ "refineincludevals",
1947
+ "refineexcludename",
1948
+ "refineexcludevals",
1949
+ "offsetincludename",
1950
+ "offsetincludevals",
1951
+ "offsetexcludename",
1952
+ "offsetexcludevals",
1953
+ ]:
1954
+ args[key] = None
1955
+
1956
+ # if brainmaskincludespec is set, set initregressorinclude, corrmaskinclude, refineinclude, and offsetinclude to it.
1957
+ brainmasks = ["initregressor", "corrmask", "refine", "offset"]
1928
1958
  if args["brainmaskincludespec"] is not None:
1929
1959
  (
1930
1960
  args["brainmaskincludename"],
@@ -1934,12 +1964,22 @@ def process_args(inputargs=None):
1934
1964
  )
1935
1965
  if not os.path.isfile(args["brainmaskincludename"]):
1936
1966
  raise FileNotFoundError(f"file {args['brainmaskincludename']} does not exist.")
1967
+ for masktype in brainmasks:
1968
+ (
1969
+ args[f"{masktype}includename"],
1970
+ args[f"{masktype}includevals"],
1971
+ ) = (
1972
+ args["brainmaskincludename"],
1973
+ args["brainmaskincludevals"],
1974
+ )
1975
+ print(f"setting {masktype}include mask to gray matter mask")
1937
1976
  else:
1938
1977
  args["brainmaskincludename"] = None
1939
1978
  args["brainmaskincludevals"] = None
1940
1979
 
1941
- # if graymatterincludespec is set, set globalmeaninclude, offsetinclude to it.
1942
- graymasks = ["globalmean", "offset"]
1980
+ # if graymatterincludespec is set, set initregressorinclude, offsetinclude to it.
1981
+ # graymasks = ["initregressor", "offset"]
1982
+ graymasks = ["initregressor"]
1943
1983
  if args["graymatterincludespec"] is not None:
1944
1984
  (
1945
1985
  args["graymatterincludename"],
@@ -1961,9 +2001,6 @@ def process_args(inputargs=None):
1961
2001
  else:
1962
2002
  args["graymatterincludename"] = None
1963
2003
  args["graymatterincludevals"] = None
1964
- for masktype in graymasks:
1965
- args[f"{masktype}includename"] = None
1966
- args[f"{masktype}includevals"] = None
1967
2004
 
1968
2005
  if args["whitematterincludespec"] is not None:
1969
2006
  (
@@ -1976,26 +2013,47 @@ def process_args(inputargs=None):
1976
2013
  args["whitematterincludename"] = None
1977
2014
  args["whitematterincludevals"] = None
1978
2015
 
1979
- if args["globalmeanincludespec"] is not None:
2016
+ if args["csfincludespec"] is not None:
1980
2017
  (
1981
- args["globalmeanincludename"],
1982
- args["globalmeanincludevals"],
2018
+ args["csfincludename"],
2019
+ args["csfincludevals"],
1983
2020
  ) = tide_io.processnamespec(
1984
- args["globalmeanincludespec"], "Including voxels where ", "in global mean."
2021
+ args["csfincludespec"], "Including voxels where ", "in CSF mask."
1985
2022
  )
2023
+ else:
2024
+ args["csfincludename"] = None
2025
+ args["csfincludevals"] = None
1986
2026
 
1987
- if args["globalmeanexcludespec"] is not None:
2027
+ # individual mask processing (including overrides)
2028
+ if args["corrmaskincludespec"] is not None:
1988
2029
  (
1989
- args["globalmeanexcludename"],
1990
- args["globalmeanexcludevals"],
2030
+ args["corrmaskincludename"],
2031
+ args["corrmaskincludevals"],
1991
2032
  ) = tide_io.processnamespec(
1992
- args["globalmeanexcludespec"],
2033
+ args["corrmaskincludespec"],
2034
+ "Including voxels where ",
2035
+ "in correlation calculations.",
2036
+ )
2037
+
2038
+ if args["initregressorincludespec"] is not None:
2039
+ (
2040
+ args["initregressorincludename"],
2041
+ args["initregressorincludevals"],
2042
+ ) = tide_io.processnamespec(
2043
+ args["initregressorincludespec"],
2044
+ "Including voxels where ",
2045
+ "in initial regressor calculation.",
2046
+ )
2047
+
2048
+ if args["initregressorexcludespec"] is not None:
2049
+ (
2050
+ args["initregressorexcludename"],
2051
+ args["initregressorexcludevals"],
2052
+ ) = tide_io.processnamespec(
2053
+ args["initregressorexcludespec"],
1993
2054
  "Excluding voxels where ",
1994
- "from global mean.",
2055
+ "from initial regressor calculation.",
1995
2056
  )
1996
- else:
1997
- args["globalmeanexcludename"] = None
1998
- args["globalmeanexcludevals"] = None
1999
2057
 
2000
2058
  if args["refineincludespec"] is not None:
2001
2059
  (
@@ -2004,9 +2062,6 @@ def process_args(inputargs=None):
2004
2062
  ) = tide_io.processnamespec(
2005
2063
  args["refineincludespec"], "Including voxels where ", "in refinement."
2006
2064
  )
2007
- else:
2008
- args["refineincludename"] = None
2009
- args["refineincludevals"] = None
2010
2065
 
2011
2066
  if args["refineexcludespec"] is not None:
2012
2067
  (
@@ -2015,9 +2070,6 @@ def process_args(inputargs=None):
2015
2070
  ) = tide_io.processnamespec(
2016
2071
  args["refineexcludespec"], "Excluding voxels where ", "from refinement."
2017
2072
  )
2018
- else:
2019
- args["refineexcludename"] = None
2020
- args["refineexcludevals"] = None
2021
2073
 
2022
2074
  if args["offsetincludespec"] is not None:
2023
2075
  (
@@ -2034,9 +2086,6 @@ def process_args(inputargs=None):
2034
2086
  ) = tide_io.processnamespec(
2035
2087
  args["offsetexcludespec"], "Excluding voxels where ", "from offset calculation."
2036
2088
  )
2037
- else:
2038
- args["offsetexcludename"] = None
2039
- args["offsetexcludevals"] = None
2040
2089
 
2041
2090
  # motion processing
2042
2091
  if args["motionfilespec"] is not None:
@@ -2091,7 +2140,7 @@ def process_args(inputargs=None):
2091
2140
  args["outputlevel"] = "min"
2092
2141
  args["dolinfitfilt"] = False
2093
2142
 
2094
- if args["globalpreselect"]:
2143
+ if args["initregressorpreselect"]:
2095
2144
  LGR.warning('Using "globalpreselect" analysis mode. Overriding any affected arguments.')
2096
2145
  args["passes"] = 1
2097
2146
  args["despeckle_passes"] = 0
@@ -2198,7 +2247,7 @@ def process_args(inputargs=None):
2198
2247
  args["territorymapname"],
2199
2248
  args["territorymapincludevals"],
2200
2249
  ) = tide_io.processnamespec(
2201
- args["territorymap"], "Including voxels where ", "in global mean."
2250
+ args["territorymap"], "Including voxels where ", "in initial regressor calculation."
2202
2251
  )
2203
2252
  else:
2204
2253
  args["territorymapname"] = None
@@ -20,6 +20,7 @@ import argparse
20
20
  import copy
21
21
  import logging
22
22
  import os
23
+ import platform
23
24
  import sys
24
25
  import time
25
26
  from pathlib import Path
@@ -28,6 +29,7 @@ import numpy as np
28
29
 
29
30
  import rapidtide.filter as tide_filt
30
31
  import rapidtide.io as tide_io
32
+ import rapidtide.maskutil as tide_mask
31
33
  import rapidtide.miscmath as tide_math
32
34
  import rapidtide.multiproc as tide_multiproc
33
35
  import rapidtide.refinedelay as tide_refinedelay
@@ -162,13 +164,13 @@ def _get_parser():
162
164
  default=True,
163
165
  )
164
166
  parser.add_argument(
165
- "--refinecorr",
167
+ "--norefinecorr",
166
168
  dest="refinecorr",
167
- action="store_true",
169
+ action="store_false",
168
170
  help=(
169
- "Recalculate the maxcorr map using GLM coefficient of determination from bandpassed data."
171
+ "Don't recalculate the maxcorr map using GLM coefficient of determination from bandpassed data."
170
172
  ),
171
- default=False,
173
+ default=True,
172
174
  )
173
175
  parser.add_argument(
174
176
  "--nofilterwithrefineddelay",
@@ -802,16 +804,142 @@ def retroregress(args):
802
804
  "message3": "voxels",
803
805
  },
804
806
  )
805
- # finalrawvariance = tide_math.imagevariance(filtereddata, None, 1.0 / fmritr)
806
807
  finalvariance = tide_math.imagevariance(filtereddata, theprefilter, 1.0 / fmritr)
807
808
 
808
809
  divlocs = np.where(finalvariance > 0.0)
809
810
  varchange = initialvariance * 0.0
810
811
  varchange[divlocs] = 100.0 * (finalvariance[divlocs] / initialvariance[divlocs] - 1.0)
811
812
 
812
- """divlocs = np.where(finalrawvariance > 0.0)
813
- rawvarchange = initialrawvariance * 0.0
814
- rawvarchange[divlocs] = 100.0 * (finalrawvariance[divlocs] / initialrawvariance[divlocs] - 1.0)"""
813
+ # save regional timecourses if masks are defined
814
+ # read in the anatomic masks
815
+ anatomiclist = [
816
+ ["brainmaskincludename", "brainmaskincludevals", "brainmask"],
817
+ ["graymatterincludename", "graymatterincludevals", "graymattermask"],
818
+ ["whitematterincludename", "whitematterincludevals", "whitemattermask"],
819
+ ["csfincludename", "csfincludevals", "csfmask"],
820
+ ]
821
+ anatomicmasks = []
822
+ for thisanatomic in anatomiclist:
823
+ try:
824
+ thename = therunoptions[thisanatomic[0]]
825
+ except KeyError:
826
+ therunoptions[thisanatomic[0]] = None
827
+ if therunoptions[thisanatomic[0]] is not None:
828
+ anatomicmasks.append(
829
+ tide_mask.readamask(
830
+ therunoptions[thisanatomic[0]],
831
+ theinputdata.nim_hdr,
832
+ xsize,
833
+ istext=(theinputdata.filetype == "text"),
834
+ valslist=therunoptions[thisanatomic[1]],
835
+ maskname=thisanatomic[2],
836
+ tolerance=therunoptions["spatialtolerance"],
837
+ debug=args.focaldebug,
838
+ )
839
+ )
840
+ anatomicmasks[-1] = np.uint16(np.where(anatomicmasks[-1] > 0.1, 1, 0))
841
+ else:
842
+ anatomicmasks.append(None)
843
+ brainmask = anatomicmasks[0]
844
+ graymask = anatomicmasks[1]
845
+ whitemask = anatomicmasks[2]
846
+ csfmask = anatomicmasks[3]
847
+
848
+ """if internalinitregressorincludemask is not None:
849
+ thisincludemask = internalinitregressorincludemask[validvoxels]
850
+ else:
851
+ thisincludemask = None
852
+ if internalinitregressorexcludemask is not None:
853
+ thisexcludemask = internalinitregressorexcludemask[validvoxels]
854
+ else:
855
+ thisexcludemask = None
856
+
857
+ meanvec, meanmask = tide_mask.saveregionaltimeseries(
858
+ "initial regressor",
859
+ "startregressormask",
860
+ filtereddata,
861
+ thisincludemask,
862
+ 1.0 / fmritr,
863
+ outputname,
864
+ initfile=True,
865
+ excludemask=thisexcludemask,
866
+ filedesc="regionalpostfilter",
867
+ suffix="",
868
+ debug=args.debug,
869
+ )"""
870
+ # reformat the anatomic masks, if they exist
871
+ if brainmask is None:
872
+ invbrainmask = None
873
+
874
+ internalbrainmask = None
875
+ internalinvbrainmask = None
876
+ else:
877
+ invbrainmask = 1 - brainmask
878
+ internalbrainmask = brainmask.reshape((numspatiallocs))
879
+ internalinvbrainmask = invbrainmask.reshape((numspatiallocs))
880
+ if graymask is None:
881
+ internalgraymask = None
882
+ else:
883
+ internalgraymask = graymask.reshape((numspatiallocs))
884
+ if whitemask is None:
885
+ internalwhitemask = None
886
+ else:
887
+ internalwhitemask = whitemask.reshape((numspatiallocs))
888
+ if csfmask is None:
889
+ internalcsfmask = None
890
+ else:
891
+ internalcsfmask = csfmask.reshape((numspatiallocs))
892
+ if brainmask is not None:
893
+ brainvec, dummy = tide_mask.saveregionaltimeseries(
894
+ "whole brain",
895
+ "brain",
896
+ filtereddata,
897
+ internalbrainmask[validvoxels],
898
+ 1.0 / fmritr,
899
+ outputname,
900
+ filedesc="regionalpostfilter",
901
+ suffix="",
902
+ debug=args.debug,
903
+ )
904
+ if graymask is not None:
905
+ grayvec, dummy = tide_mask.saveregionaltimeseries(
906
+ "gray matter",
907
+ "GM",
908
+ filtereddata,
909
+ internalgraymask[validvoxels],
910
+ 1.0 / fmritr,
911
+ outputname,
912
+ excludemask=internalinvbrainmask[validvoxels],
913
+ filedesc="regionalpostfilter",
914
+ suffix="",
915
+ debug=args.debug,
916
+ )
917
+ if whitemask is not None:
918
+ whitevec, dummy = tide_mask.saveregionaltimeseries(
919
+ "white matter",
920
+ "WM",
921
+ filtereddata,
922
+ internalwhitemask[validvoxels],
923
+ 1.0 / fmritr,
924
+ outputname,
925
+ excludemask=internalinvbrainmask[validvoxels],
926
+ filedesc="regionalpostfilter",
927
+ suffix="",
928
+ debug=args.debug,
929
+ )
930
+ if csfmask is not None:
931
+ grayvec, dummy = tide_mask.saveregionaltimeseries(
932
+ "CSF",
933
+ "CSF",
934
+ filtereddata,
935
+ internalcsfmask[validvoxels],
936
+ 1.0 / fmritr,
937
+ outputname,
938
+ excludemask=internalinvbrainmask[validvoxels],
939
+ filedesc="regionalpostfilter",
940
+ suffix="",
941
+ debug=args.debug,
942
+ )
815
943
 
816
944
  # save outputs
817
945
  TimingLGR.info("Starting output save")
@@ -899,8 +1027,20 @@ def retroregress(args):
899
1027
  "second",
900
1028
  "Lag time in seconds used for calculation",
901
1029
  ),
902
- (corrmask_valid, "corrfitREAD", "mask", None, "Correlation mask used for calculation"),
903
- (procmask_valid, "processedREAD", "mask", None, "Processed mask used for calculation"),
1030
+ (
1031
+ corrmask_valid,
1032
+ "corrfitREAD",
1033
+ "mask",
1034
+ None,
1035
+ "Correlation mask used for calculation",
1036
+ ),
1037
+ (
1038
+ procmask_valid,
1039
+ "processedREAD",
1040
+ "mask",
1041
+ None,
1042
+ "Processed mask used for calculation",
1043
+ ),
904
1044
  ]
905
1045
  if args.savenormalsLFOfiltfiles:
906
1046
  if args.regressderivs > 0 or args.refinedelay:
@@ -1102,43 +1242,45 @@ def retroregress(args):
1102
1242
  TimingLGR.info("Finishing output save")
1103
1243
 
1104
1244
  if args.refinecorr:
1105
- TimingLGR.info("Filtering for maxcorralt calculation start")
1245
+ TimingLGR.info("Filtering for maxcorrrefined calculation start")
1106
1246
  for thevoxel in range(fmri_data_valid.shape[0]):
1107
1247
  fmri_data_valid[thevoxel, :] = theprefilter.apply(
1108
1248
  1.0 / fmritr, fmri_data_valid[thevoxel, :]
1109
1249
  )
1110
- TimingLGR.info("Filtering for maxcorralt calculation complete")
1111
- TimingLGR.info("GLM for maxcorralt calculation start")
1112
- voxelsprocessed_regressionfilt, regressorset, evset = tide_regressfrommaps.regressfrommaps(
1113
- fmri_data_valid,
1114
- validvoxels,
1115
- initial_fmri_x,
1116
- lagstouse_valid,
1117
- corrmask_valid,
1118
- genlagtc,
1119
- mode,
1120
- outputname,
1121
- oversamptr,
1122
- sLFOfitmean,
1123
- rvalue,
1124
- r2value,
1125
- fitNorm[:, : args.regressderivs + 1],
1126
- fitcoeff[:, : args.regressderivs + 1],
1127
- movingsignal,
1128
- lagtc,
1129
- filtereddata,
1130
- LGR,
1131
- TimingLGR,
1132
- threshval,
1133
- args.saveminimumsLFOfiltfiles,
1134
- nprocs_makelaggedtcs=args.nprocs,
1135
- nprocs_regressionfilt=args.nprocs,
1136
- regressderivs=args.regressderivs,
1137
- showprogressbar=args.showprogressbar,
1138
- debug=args.debug,
1250
+ TimingLGR.info("Filtering for maxcorrrefined calculation complete")
1251
+ TimingLGR.info("GLM for maxcorrrefined calculation start")
1252
+ voxelsprocessed_regressionfilt, regressorset, evset = (
1253
+ tide_regressfrommaps.regressfrommaps(
1254
+ fmri_data_valid,
1255
+ validvoxels,
1256
+ initial_fmri_x,
1257
+ lagstouse_valid,
1258
+ corrmask_valid,
1259
+ genlagtc,
1260
+ mode,
1261
+ outputname,
1262
+ oversamptr,
1263
+ sLFOfitmean,
1264
+ rvalue,
1265
+ r2value,
1266
+ fitNorm[:, : args.regressderivs + 1],
1267
+ fitcoeff[:, : args.regressderivs + 1],
1268
+ movingsignal,
1269
+ lagtc,
1270
+ filtereddata,
1271
+ LGR,
1272
+ TimingLGR,
1273
+ threshval,
1274
+ args.saveminimumsLFOfiltfiles,
1275
+ nprocs_makelaggedtcs=args.nprocs,
1276
+ nprocs_regressionfilt=args.nprocs,
1277
+ regressderivs=args.regressderivs,
1278
+ showprogressbar=args.showprogressbar,
1279
+ debug=args.debug,
1280
+ )
1139
1281
  )
1140
1282
  TimingLGR.info(
1141
- "GLM for maxcorralt calculation done",
1283
+ "GLM for maxcorrrefined calculation done",
1142
1284
  {
1143
1285
  "message2": voxelsprocessed_regressionfilt,
1144
1286
  "message3": "voxels",
@@ -1148,7 +1290,7 @@ def retroregress(args):
1148
1290
  maplist = [
1149
1291
  (
1150
1292
  rvalue,
1151
- "maxcorralt",
1293
+ "maxcorrrefined",
1152
1294
  "map",
1153
1295
  None,
1154
1296
  "R value for the lfo component of the delayed regressor, with sign",
@@ -1241,7 +1383,6 @@ def retroregress(args):
1241
1383
  debug=args.debug,
1242
1384
  )
1243
1385
 
1244
-
1245
1386
  # write the runoptions file
1246
1387
  print("writing runoptions")
1247
1388
  if args.refinedelay:
@@ -1249,6 +1390,14 @@ def retroregress(args):
1249
1390
  therunoptions["retroregress_runtime"] = time.strftime(
1250
1391
  "%a, %d %b %Y %H:%M:%S %Z", time.localtime(time.time())
1251
1392
  )
1393
+ (
1394
+ therunoptions["retroregress_release_version"],
1395
+ therunoptions["retroregress_git_sha"],
1396
+ therunoptions["retroregress_git_date"],
1397
+ therunoptions["retroregress_git_isdirty"],
1398
+ ) = tide_util.version()
1399
+ therunoptions["retroregress_python_version"] = str(sys.version_info)
1400
+ therunoptions["retroregress_nodename"] = platform.node()
1252
1401
 
1253
1402
  # clean up shared memory
1254
1403
  if usesharedmem: