rapidtide 3.0.5__py3-none-any.whl → 3.0.7__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.
Files changed (45) hide show
  1. rapidtide/RapidtideDataset.py +17 -0
  2. rapidtide/_version.py +3 -3
  3. rapidtide/calccoherence.py +51 -73
  4. rapidtide/calcnullsimfunc.py +65 -111
  5. rapidtide/calcsimfunc.py +73 -91
  6. rapidtide/correlate.py +25 -6
  7. rapidtide/data/examples/src/testatlasaverage +22 -0
  8. rapidtide/data/examples/src/testfmri +16 -1
  9. rapidtide/data/examples/src/testhappy +57 -60
  10. rapidtide/data/examples/src/testsimdata +45 -28
  11. rapidtide/genericmultiproc.py +122 -0
  12. rapidtide/happy_supportfuncs.py +608 -107
  13. rapidtide/linfitfiltpass.py +8 -1
  14. rapidtide/makelaggedtcs.py +49 -78
  15. rapidtide/multiproc.py +5 -17
  16. rapidtide/refineregressor.py +59 -81
  17. rapidtide/resample.py +24 -14
  18. rapidtide/tests/.coveragerc +9 -0
  19. rapidtide/tests/test_congrid.py +68 -79
  20. rapidtide/tests/test_externaltools.py +69 -0
  21. rapidtide/tests/test_fastresampler.py +1 -0
  22. rapidtide/tests/test_fullrunrapidtide_v2.py +1 -0
  23. rapidtide/tests/test_nullcorr.py +2 -5
  24. rapidtide/tests/test_parserfuncs.py +46 -15
  25. rapidtide/tests/test_zRapidtideDataset.py +2 -2
  26. rapidtide/voxelData.py +17 -3
  27. rapidtide/workflows/ccorrica.py +1 -2
  28. rapidtide/workflows/cleanregressor.py +3 -2
  29. rapidtide/workflows/happy.py +62 -3
  30. rapidtide/workflows/happy_parser.py +36 -0
  31. rapidtide/workflows/rapidtide.py +18 -13
  32. rapidtide/workflows/rapidtide_parser.py +8 -1
  33. rapidtide/workflows/regressfrommaps.py +0 -2
  34. rapidtide/workflows/showarbcorr.py +19 -6
  35. rapidtide/workflows/showxcorrx.py +4 -8
  36. rapidtide/workflows/simdata.py +149 -65
  37. {rapidtide-3.0.5.dist-info → rapidtide-3.0.7.dist-info}/METADATA +1 -1
  38. {rapidtide-3.0.5.dist-info → rapidtide-3.0.7.dist-info}/RECORD +42 -43
  39. {rapidtide-3.0.5.dist-info → rapidtide-3.0.7.dist-info}/WHEEL +1 -1
  40. rapidtide/DerivativeDelay.py +0 -209
  41. rapidtide/calcandfitcorrpairs.py +0 -262
  42. rapidtide/transformerdlfilter.py +0 -126
  43. {rapidtide-3.0.5.dist-info → rapidtide-3.0.7.dist-info}/entry_points.txt +0 -0
  44. {rapidtide-3.0.5.dist-info → rapidtide-3.0.7.dist-info}/licenses/LICENSE +0 -0
  45. {rapidtide-3.0.5.dist-info → rapidtide-3.0.7.dist-info}/top_level.txt +0 -0
@@ -21,3 +21,25 @@ atlasaverage \
21
21
  --extramask /opt/fsl-latest/data/standard/MNI152_T1_1mm_brain_mask.nii.gz \
22
22
  --summarymethod median \
23
23
  --headerline
24
+
25
+ atlasaverage \
26
+ sub-RAPIDTIDETEST.nii.gz \
27
+ sub-RAPIDTIDETEST_dseg.nii.gz \
28
+ ../dst/synthsegaverages \
29
+ --ignorezeros \
30
+ --numpercentiles 3 \
31
+ --includemask sub-RAPIDTIDETEST_brainmask.nii.gz \
32
+ --regionlabelfile dseglabels.txt \
33
+ --summarymethod mean
34
+
35
+ atlasaverage \
36
+ sub-RAPIDTIDETEST.nii.gz \
37
+ sub-RAPIDTIDETEST_dseg.nii.gz \
38
+ ../dst/synthsegaverages_pctnorm \
39
+ --normmethod pct \
40
+ --ignorezeros \
41
+ --numpercentiles 3 \
42
+ --includemask sub-RAPIDTIDETEST_brainmask.nii.gz \
43
+ --regionlabelfile dseglabels.txt \
44
+ --summarymethod mean
45
+
@@ -6,10 +6,25 @@ rapidtide \
6
6
  --searchrange -5 20 \
7
7
  --simcalcrange 50 -1 \
8
8
  --outputlevel more \
9
- --dofinalrefine \
10
9
  --graymattermask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_GRAY \
11
10
  --brainmask sub-RAPIDTIDETEST_brainmask.nii.gz \
12
11
  --whitemattermask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_WHITE \
13
12
  --csfmask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_CSF \
13
+ --cleanrefined \
14
14
  sub-RAPIDTIDETEST.nii.gz \
15
15
  ../dst/sub-RAPIDTIDETEST
16
+
17
+ rapidtide \
18
+ --spatialfilt -1 \
19
+ --nprocs -1 \
20
+ --searchrange -5 20 \
21
+ --simcalcrange 50 -1 \
22
+ --outputlevel more \
23
+ --nosLFOfiltmask \
24
+ --graymattermask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_GRAY \
25
+ --brainmask sub-RAPIDTIDETEST_brainmask.nii.gz \
26
+ --whitemattermask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_WHITE \
27
+ --csfmask sub-RAPIDTIDETEST_synthseg.nii.gz:SSEG_CSF \
28
+ --cleanrefined \
29
+ sub-RAPIDTIDETEST.nii.gz \
30
+ ../dst/sub-RAPIDTIDETEST_nosLFOfiltmask
@@ -1,80 +1,77 @@
1
1
  #!/bin/csh -f
2
2
 
3
3
  #happy \
4
- # ~/Dropbox_PHC/MR_data_2/physioconn/rfMRI_REST1_LR/100206_3T_rfMRI_REST1_LR.nii.gz \
5
- # ~/Dropbox_PHC/MR_data_2/physioconn/rfMRI_REST1_LR/slicetimes.txt \
6
- # ~/Dropbox_PHC/MR_data_2/physioconn/happytest/happyarm \
7
- # --mklthreads -1 \
8
- # --infotag tag1 value1 \
9
- # --infotag tag2 value2 \
10
- # --model model_revised
4
+ # sub-HAPPYTEST.nii.gz \
5
+ # sub-HAPPYTEST.json \
6
+ # ../dst/happy_vanilla \
7
+ # --nprocs 1
11
8
 
12
9
  #happy \
13
- #sub-HAPPYTEST.nii.gz \
14
- #sub-HAPPYTEST.json \
15
- #../dst/happy \
16
- #--mklthreads 8 \
17
- #--model model_revised \
18
- #--spatialglm --aliasedcorrelation
19
-
10
+ # sub-HAPPYTEST.nii.gz \
11
+ # sub-HAPPYTEST.json \
12
+ # --mpphaseproject \
13
+ # ../dst/happy_mpphaseproj \
14
+ # --nprocs -1
20
15
 
21
16
  #happy \
22
17
  # sub-HAPPYTEST.nii.gz \
23
18
  # sub-HAPPYTEST.json \
24
- # ../dst/happy_2comp \
25
- # --cardiacfile happystdres_bids.tsv:normcardiac_25.0Hz \
26
- # --mklthreads 8 \
27
- # --hilbertcomponents 2 \
28
- # --model model_revised
29
- #
19
+ # --mpdetrend \
20
+ # ../dst/happy_mpdetrend \
21
+ # --nprocs -1
22
+
30
23
  #happy \
31
24
  # sub-HAPPYTEST.nii.gz \
32
25
  # sub-HAPPYTEST.json \
33
- # ../dst/happy_3comp \
34
- # --cardiacfile happystdres_bids.tsv:normcardiac_25.0Hz \
35
- # --mklthreads 8 \
36
- # --hilbertcomponents 3 \
37
- # --model model_revised
26
+ # --mpphaseproject \
27
+ # --mpdetrend \
28
+ # ../dst/happy_mpdetrend_mpphaseproj \
29
+ # --nprocs -1
38
30
 
39
- #happy_legacy \
40
- #sub-HAPPYTEST.nii.gz \
41
- #sub-HAPPYTEST.json \
42
- #../dst/happy_normaltest \
43
- #--mklthreads=8 \
44
- #--model=model_revised \
45
- #--outputbins=40 \
46
- #--gridbins=3.5 \
47
- #--stdfreq=20.0 \
48
- #--estmask=happytestvesselmask.nii.gz \
49
- #--minhr=46 \
50
- #--maxhr=131.2 \
51
- #--minhrfilt=45.5 \
52
- #--maxhrfilt=800.0 \
53
- #--envcutoff=0.45 \
54
- #--notchwidth=1.25 \
55
- #--cardiacfile=happytestpleth.txt \
56
- #--cardiacfreq=20.0 \
57
- #--cardiacstart=0.0 \
58
- #--aliasedcorrelation \
59
- #--increaseoutputlevel \
60
- #--increaseoutputlevel \
61
- #--decreaseoutputlevel \
62
- #--dodlfilter
31
+ #happy \
32
+ # sub-HAPPYTEST.nii.gz \
33
+ # sub-HAPPYTEST.json \
34
+ # --prefillcongrid \
35
+ # ../dst/happy_vanilla_prefill \
36
+ # --nprocs 1
63
37
 
38
+ #happy \
39
+ # sub-HAPPYTEST.nii.gz \
40
+ # sub-HAPPYTEST.json \
41
+ # --prefillcongrid \
42
+ # --mpphaseproject \
43
+ # ../dst/happy_mpphaseproj_prefill \
44
+ # --nprocs -1
64
45
 
65
- happy \
66
- sub-HAPPYTEST.nii.gz \
67
- sub-HAPPYTEST.json \
68
- ../dst/happy
46
+ #happy \
47
+ # sub-HAPPYTEST.nii.gz \
48
+ # sub-HAPPYTEST.json \
49
+ # --prefillcongrid \
50
+ # --mpdetrend \
51
+ # ../dst/happy_mpdetrend_prefill \
52
+ # --nprocs -1
69
53
 
70
- happy \
71
- sub-HAPPYTEST.nii.gz \
72
- sub-HAPPYTEST.json \
73
- --model ~/code/rapidtide/rapidtide/data/models/model_cnn_w064_l13_fn20_fl08 \
74
- ../dst/happy_newcnn
54
+ #happy \
55
+ # sub-HAPPYTEST.nii.gz \
56
+ # sub-HAPPYTEST.json \
57
+ # --prefillcongrid \
58
+ # --mpphaseproject \
59
+ # --mpdetrend \
60
+ # ../dst/happy_mpdetrend_mpphaseproj_prefill \
61
+ # --nprocs -1
75
62
 
76
63
  #happy \
77
64
  #sub-HAPPYTEST.nii.gz \
78
65
  #sub-HAPPYTEST.json \
79
- #../dst/happy
80
- #
66
+ #--mpphaseproject \
67
+ #--mpdetrend \
68
+ #--nocongridcache \
69
+ #../dst/happy_mpdetrend_mpphaseproj_nocache \
70
+ #--nprocs -1
71
+
72
+ happy \
73
+ sub-HAPPYTEST.nii.gz \
74
+ sub-HAPPYTEST.json \
75
+ ../dst/happy_newdefaults \
76
+ --aliasedcorrelation \
77
+ --nprocs -1
@@ -1,36 +1,53 @@
1
1
  #!/bin/bash
2
2
 
3
+ #rapidtide \
4
+ # --spatialfilt -1 \
5
+ # --nprocs -1 \
6
+ # --searchrange -5 20 \
7
+ # --simcalcrange 50 -1 \
8
+ # --outputlevel more \
9
+ # --nofitfilt \
10
+ # --corrtype linear \
11
+ # sub-RAPIDTIDETEST.nii.gz \
12
+ # ../dst/sub-RAPIDTIDETEST
13
+
14
+ simdata \
15
+ 1.5 \
16
+ 260 \
17
+ ../dst/sub-RAPIDTIDETEST_desc-unfiltmean_map.nii.gz \
18
+ ../dst/simulatedfmri_vn05 \
19
+ --lfopctfile ../dst/sub-RAPIDTIDETEST_desc-maxcorr_map.nii.gz \
20
+ --lfolagfile ../dst/sub-RAPIDTIDETEST_desc-maxtimerefined_map.nii.gz \
21
+ --lforegressor ../dst/sub-RAPIDTIDETEST_desc-movingregressor_timeseries.json:pass3 \
22
+ --voxelnoiselevel 5.0
23
+
3
24
  rapidtide \
4
- --spatialfilt 2 \
5
- --nprocs -1 \
6
- --passes 3 \
7
- --nofitfilt \
8
- --similaritymetric hybrid \
9
- --norefinedespeckled \
10
- --filterband lfo \
11
- --corrtype linear \
12
- sub-RAPIDTIDETEST.nii.gz \
13
- ../dst/sub-RAPIDTIDETEST
25
+ --spatialfilt -1 \
26
+ --nprocs -1 \
27
+ --searchrange -5 20 \
28
+ --simcalcrange 50 -1 \
29
+ --outputlevel more \
30
+ --nofitfilt \
31
+ --corrtype linear \
32
+ ../dst/simulatedfmri_vn05.nii.gz \
33
+ ../dst/simrapidtide_vn05
14
34
 
15
35
  simdata \
16
- sub-RAPIDTIDETEST.nii.gz \
17
- ../dst/sub-RAPIDTIDETEST_desc-mean_map.nii.gz \
18
- ../dst/simulatedfmri \
19
- sub-RAPIDTIDETEST.json \
20
- --lfopctfile ../dst/sub-RAPIDTIDETEST_desc-corrfit_mask.nii.gz \
21
- --lfolagfile ../dst/sub-RAPIDTIDETEST_desc-maxtime_map.nii.gz \
36
+ 1.5 \
37
+ 260 \
38
+ ../dst/sub-RAPIDTIDETEST_desc-unfiltmean_map.nii.gz \
39
+ ../dst/simulatedfmri_sigfrac \
40
+ --lfosignalfraction ../dst/sub-RAPIDTIDETEST_desc-lfofilterInbandVarianceChange_map.nii.gz \
41
+ --lfolagfile ../dst/sub-RAPIDTIDETEST_desc-maxtimerefined_map.nii.gz \
22
42
  --lforegressor ../dst/sub-RAPIDTIDETEST_desc-movingregressor_timeseries.json:pass3
23
43
 
24
44
  rapidtide \
25
- --spatialfilt 2 \
26
- --nprocs -1 \
27
- --passes 3 \
28
- --nofitfilt \
29
- --similaritymetric hybrid \
30
- --regressor ../dst/sub-RAPIDTIDETEST_desc-movingregressor_timeseries.json:pass3 \
31
- --CVR \
32
- --filterband lfo \
33
- --corrtype linear \
34
- ../dst/simulatedfmri.nii.gz \
35
- ../dst/simrapidtide
36
-
45
+ --spatialfilt -1 \
46
+ --nprocs -1 \
47
+ --searchrange -5 20 \
48
+ --simcalcrange 50 -1 \
49
+ --outputlevel more \
50
+ --nofitfilt \
51
+ --corrtype linear \
52
+ ../dst/simulatedfmri_sigfrac.nii.gz \
53
+ ../dst/simrapidtide_sigfrac
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ # Copyright 2016-2025 Blaise Frederick
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ #
19
+ import gc
20
+ import logging
21
+
22
+ import numpy as np
23
+ from tqdm import tqdm
24
+
25
+ import rapidtide.multiproc as tide_multiproc
26
+
27
+
28
+ def run_multiproc(
29
+ voxelfunc,
30
+ packfunc,
31
+ unpackfunc,
32
+ voxelargs,
33
+ voxelproducts,
34
+ inputshape,
35
+ voxelmask,
36
+ LGR,
37
+ nprocs,
38
+ alwaysmultiproc,
39
+ showprogressbar,
40
+ chunksize,
41
+ indexaxis=0,
42
+ procunit="voxels",
43
+ debug=False,
44
+ **kwargs,
45
+ ):
46
+ if debug:
47
+ print(f"{len(voxelproducts)=}, {voxelproducts[0].shape}")
48
+ if nprocs > 1 or alwaysmultiproc:
49
+ # define the consumer function here so it inherits most of the arguments
50
+ def theconsumerfunc(inQ, outQ):
51
+ while True:
52
+ try:
53
+ # get a new message
54
+ val = inQ.get()
55
+
56
+ # this is the 'TERM' signal
57
+ if val is None:
58
+ break
59
+
60
+ # process and send the data
61
+ outQ.put(
62
+ voxelfunc(
63
+ val,
64
+ packfunc(val, voxelargs),
65
+ debug=debug,
66
+ **kwargs,
67
+ )
68
+ )
69
+ except Exception as e:
70
+ print("error!", e)
71
+ break
72
+
73
+ data_out = tide_multiproc.run_multiproc(
74
+ theconsumerfunc,
75
+ inputshape,
76
+ voxelmask,
77
+ indexaxis=indexaxis,
78
+ procunit=procunit,
79
+ verbose=(LGR is not None),
80
+ nprocs=nprocs,
81
+ showprogressbar=showprogressbar,
82
+ chunksize=chunksize,
83
+ )
84
+
85
+ # unpack the data
86
+ volumetotal = 0
87
+ for returnvals in data_out:
88
+ volumetotal += 1
89
+ unpackfunc(returnvals, voxelproducts)
90
+ del data_out
91
+ else:
92
+ volumetotal = 0
93
+ for vox in tqdm(
94
+ range(0, inputshape[indexaxis]),
95
+ desc="Voxel",
96
+ unit=procunit,
97
+ disable=(not showprogressbar),
98
+ ):
99
+ if voxelmask[vox] > 0:
100
+ dothisone = True
101
+ else:
102
+ dothisone = False
103
+ if dothisone:
104
+ returnvals = voxelfunc(
105
+ vox,
106
+ packfunc(vox, voxelargs),
107
+ debug=debug,
108
+ **kwargs,
109
+ )
110
+ unpackfunc(returnvals, voxelproducts)
111
+ volumetotal += 1
112
+
113
+ # garbage collect
114
+ uncollected = gc.collect()
115
+ if uncollected != 0:
116
+ if LGR is not None:
117
+ LGR.info(f"garbage collected - unable to collect {uncollected} objects")
118
+ else:
119
+ if LGR is not None:
120
+ LGR.info("garbage collected")
121
+
122
+ return volumetotal