fmri-qctoolkit 1.0.0__tar.gz

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 (72) hide show
  1. fmri_qctoolkit-1.0.0/CHANGELOG.md +89 -0
  2. fmri_qctoolkit-1.0.0/CITATION.cff +20 -0
  3. fmri_qctoolkit-1.0.0/LICENSE +201 -0
  4. fmri_qctoolkit-1.0.0/MANIFEST.in +5 -0
  5. fmri_qctoolkit-1.0.0/PKG-INFO +287 -0
  6. fmri_qctoolkit-1.0.0/README.md +246 -0
  7. fmri_qctoolkit-1.0.0/examples/example_data/data_generators.py +163 -0
  8. fmri_qctoolkit-1.0.0/examples/example_data/fmriprep/df_final.csv +32 -0
  9. fmri_qctoolkit-1.0.0/examples/example_data/fmriprep/group_bold.tsv +16 -0
  10. fmri_qctoolkit-1.0.0/examples/example_data/fmriprep/lollipop_chart_data.csv +280 -0
  11. fmri_qctoolkit-1.0.0/examples/example_data/fmriprep_big/df_final.csv +301 -0
  12. fmri_qctoolkit-1.0.0/examples/example_data/fmriprep_big/lollipop_chart_data.csv +2701 -0
  13. fmri_qctoolkit-1.0.0/examples/example_data/random_data/afni_quan_data.csv +6 -0
  14. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_quan_data.csv +16 -0
  15. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_quan_data.tsv +16 -0
  16. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-001_ses-01_nback.csv +2 -0
  17. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-001_ses-02_rest.csv +2 -0
  18. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-001_ses-03_nback.csv +2 -0
  19. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-002_ses-01_nback.csv +2 -0
  20. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-002_ses-02_rest.csv +2 -0
  21. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-003_ses-01_nback.csv +2 -0
  22. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-003_ses-02_rest.csv +2 -0
  23. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-003_ses-03_nback.csv +2 -0
  24. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-004_ses-01_nback.csv +2 -0
  25. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_rating/sub-005_ses-01_nback.csv +2 -0
  26. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_selected_quan_data.csv +6 -0
  27. fmri_qctoolkit-1.0.0/examples/example_data/random_data/fmriprep_selected_quan_data.tsv +6 -0
  28. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/__init__.py +11 -0
  29. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/cli.py +240 -0
  30. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/__init__.py +13 -0
  31. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/afni_app.py +28 -0
  32. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/afni_config.json +108 -0
  33. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/base_app.py +536 -0
  34. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/fmriprep_app.py +28 -0
  35. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/fmriprep_config.json +128 -0
  36. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/fmriprep_rating_app.py +557 -0
  37. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/static/qc_rating.css +145 -0
  38. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/static/qc_rating.js +202 -0
  39. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/dashboard/templates/base.html +43 -0
  40. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/data/__init__.py +13 -0
  41. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/data/afni_pipeline.py +272 -0
  42. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/data/base.py +153 -0
  43. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/data/fmriprep_pipeline.py +276 -0
  44. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/utils/__init__.py +23 -0
  45. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/utils/access.py +77 -0
  46. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/utils/filter_components_utils.py +160 -0
  47. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/utils/plots.py +366 -0
  48. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/utils/port_utils.py +22 -0
  49. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/utils/status.py +120 -0
  50. fmri_qctoolkit-1.0.0/fMRI_QCtoolkit/utils/subject_utils.py +71 -0
  51. fmri_qctoolkit-1.0.0/fmri_qctoolkit.egg-info/PKG-INFO +287 -0
  52. fmri_qctoolkit-1.0.0/fmri_qctoolkit.egg-info/SOURCES.txt +70 -0
  53. fmri_qctoolkit-1.0.0/fmri_qctoolkit.egg-info/dependency_links.txt +1 -0
  54. fmri_qctoolkit-1.0.0/fmri_qctoolkit.egg-info/entry_points.txt +2 -0
  55. fmri_qctoolkit-1.0.0/fmri_qctoolkit.egg-info/requires.txt +14 -0
  56. fmri_qctoolkit-1.0.0/fmri_qctoolkit.egg-info/top_level.txt +1 -0
  57. fmri_qctoolkit-1.0.0/pyproject.toml +68 -0
  58. fmri_qctoolkit-1.0.0/setup.cfg +4 -0
  59. fmri_qctoolkit-1.0.0/tests/__init__.py +0 -0
  60. fmri_qctoolkit-1.0.0/tests/conftest.py +208 -0
  61. fmri_qctoolkit-1.0.0/tests/test_access.py +211 -0
  62. fmri_qctoolkit-1.0.0/tests/test_afni_pipeline.py +234 -0
  63. fmri_qctoolkit-1.0.0/tests/test_cli.py +56 -0
  64. fmri_qctoolkit-1.0.0/tests/test_dashboard.py +181 -0
  65. fmri_qctoolkit-1.0.0/tests/test_filter_components.py +161 -0
  66. fmri_qctoolkit-1.0.0/tests/test_fmriprep_pipeline.py +435 -0
  67. fmri_qctoolkit-1.0.0/tests/test_fmriprep_rating.py +930 -0
  68. fmri_qctoolkit-1.0.0/tests/test_integration.py +75 -0
  69. fmri_qctoolkit-1.0.0/tests/test_plots.py +92 -0
  70. fmri_qctoolkit-1.0.0/tests/test_port_utils.py +38 -0
  71. fmri_qctoolkit-1.0.0/tests/test_status.py +192 -0
  72. fmri_qctoolkit-1.0.0/tests/test_subject_utils.py +124 -0
@@ -0,0 +1,89 @@
1
+ # Change Log
2
+
3
+ ## [Unreleased]
4
+
5
+
6
+ ## [1.0.0] - 2026-10-24
7
+ ### Security
8
+ - The rating interface and dashboards now require a per-session token. The terminal prints a link containing it; requests without it get "Access denied". This keeps other users on a shared machine (such as an HPC login node) out of the pages and the ratings.
9
+ - Requests whose Host header is not a loopback name are refused while the server is bound to localhost, which blocks DNS rebinding from web pages.
10
+ - Subject labels in rating URLs and saves must be alphanumeric BIDS labels. Before, a crafted label could read `.html` files and write ratings outside the input and output directories on Windows.
11
+ - `fmriqc rating afni` no longer runs `open_apqc.py` through a shell, so paths with spaces or shell characters are passed as-is.
12
+ - `fmriqc dashboard --debug` is refused on a non-loopback `--host`, and a non-loopback host prints a warning.
13
+
14
+ ### Fixed
15
+ - Ratings are no longer lost when one session contains more than one task.
16
+ - Ratings are no longer lost when a task has several acquisitions, directions, or echoes.
17
+ - Run numbers in the exported CSV now match the run labels shown in the fMRIPrep report.
18
+ - Fieldmap panels are no longer counted as tasks.
19
+ - Subject IDs keep their leading zeros; `sub-0030` and `sub-30` are no longer the same subject.
20
+ - Subject IDs are no longer truncated when they start with a letter from `sub-` (`s001` became `001`).
21
+ - Non-numeric subject labels such as `sub-A01` no longer crash `fmriqc prep`.
22
+ - `fmriqc prep` now warns when the ratings and MRIQC have no records in common.
23
+ - The dashboard heatmaps no longer crash on non-numeric subject labels (`sub-A01`) or session labels (`ses-pre`), or with pandas 3.
24
+ - Changing a dashboard filter no longer moves the table selection to another run or session of the same subject, so "Download Selected Data" exports the runs that were selected.
25
+ - fMRIPrep ratings are no longer lost when a rating CSV cannot be written (for example while it is open in Excel); the save reports the locked file.
26
+ - Ratings for an fMRIPrep report with only anatomical items can now be saved.
27
+ - Two fMRIPrep report groups no longer share one rating when an acquisition, direction, or run label appears on only some of a task's groups.
28
+ - On Windows, a second `fmriqc dashboard` or `fmriqc rating fmriprep` no longer picks a port that another one is already serving, which showed up as "Access denied".
29
+ - `fmriqc dashboard --host 0.0.0.0` and IPv6 hosts now print a link that opens.
30
+ - A rating that cannot be saved because the server restarted now says to open the new link, instead of reporting a network error.
31
+ - `fmriqc prep afni` no longer keeps only one session when `--task` matches a subject in several sessions; it stops and lists the matches so `--task` can be narrowed to one session.
32
+ - `fmriqc prep afni` now accepts alphanumeric subject labels (`sub-A01`) and treats `--prefix` literally.
33
+
34
+ ### Changed
35
+ - **The command is now `fmriqc` instead of `qc` (`fmriqc prep`, `fmriqc rating`, `fmriqc dashboard`).**
36
+ - `fmriqc rating afni --afni-path` no longer defaults to a cluster-specific path; `open_apqc.py` is taken from `$PATH` unless the option is given.
37
+ - Session labels are kept as written (`ses-pre`, `ses-V1`) instead of being forced to numbers.
38
+ - Subject IDs are kept as labels rather than numbers throughout.
39
+ - The dashboard heatmaps redraw about three times faster after a filter change.
40
+ - Dependencies now have minimum versions (Dash 2.17 to 4.x, pandas 2.1, NumPy 1.26, Plotly 5.20, Flask 3.0, Typer 0.16).
41
+
42
+ ### Added
43
+ - First release on PyPI: `pip install fmri-qctoolkit`.
44
+ - `fmriqc rating fmriprep --no-browser` prints the links without opening browser tabs. Tabs are also not opened on Linux when no display is available.
45
+ - Unit tests for the dashboard's heatmap data.
46
+
47
+ ### Removed
48
+ - `BaseDataProcessor.from_files`, unused and broken since it was added.
49
+ - The unused `flask-cors` dependency.
50
+
51
+ ### Notes
52
+ - Anatomical items (T1mask / Norm / SurfRecon) can show more than one image if the subject was processed by fMRIPrep more than once. See the README.
53
+ - Ratings for a task split by acquisition or direction are saved but not yet shown in the dashboard. The rating app says so when the subject is opened, and `fmriqc prep` lists the files it skips.
54
+
55
+
56
+ ## [0.11.0] - 2026-06-12
57
+ ### Added
58
+ - "Select All (filtered)" and "Clear" buttons in the dashboard table.
59
+ - Horizontal scroll for the heatmap when there are many subjects.
60
+
61
+ ### Changed
62
+ - fMRIPrep rating now reloads from a JSON sidecar; CSV is kept as export only.
63
+ - Heatmap redrawn as a discrete square-marker grid.
64
+ - Lollipop chart split into stacked panels by session and run.
65
+
66
+ ### Removed
67
+ - CSV-column reverse-mapping on rating reload.
68
+
69
+
70
+ ## [0.10.0-beta.1] - 2025-11-04
71
+ ### Added
72
+ - Added a test script for fMRIPrep rating.
73
+
74
+ ### Changed
75
+ - Updated heatmap grouping methods.
76
+ - Improved fMRIPrep preprocessing program: dropped missing values and added common modules.
77
+
78
+
79
+ ## [0.10.0-alpha.1] - 2025-10-27
80
+ ### Added
81
+ - Support for handling `session` in fMRIPrep front end; defaults to `1` if session/run not detected.
82
+ - Data simulation module.
83
+
84
+ ### Changed
85
+ - `gsr_x` and `gsr_y` now remain unchanged instead of being averaged.
86
+ - Aggregation method for MRIQC and fMRIPrep scoring changed from `inner` to `outer`.
87
+
88
+ ### Notes
89
+ - Additional tests needed for session detection feature in fMRIPrep Rating.
@@ -0,0 +1,20 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it as below."
3
+ type: software
4
+ title: "fMRI-QCtoolkit"
5
+ abstract: "Quality control dashboard and manual rating tools for AFNI and fMRIPrep outputs, combined with MRIQC metrics."
6
+ authors:
7
+ - given-names: Qiuyu
8
+ family-names: Yu
9
+ email: qiuyuyu.psych@gmail.com
10
+ orcid: "https://orcid.org/0009-0003-5242-6302"
11
+ version: 1.0.0
12
+ date-released: "2026-10-24"
13
+ license: Apache-2.0
14
+ repository-code: "https://github.com/QiuyuYu3/fMRI-QCtoolkit"
15
+ keywords:
16
+ - fMRI
17
+ - quality control
18
+ - MRIQC
19
+ - fMRIPrep
20
+ - AFNI
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ recursive-include fMRI_QCtoolkit *
2
+ include CHANGELOG.md CITATION.cff
3
+ graft tests
4
+ graft examples/example_data
5
+ global-exclude __pycache__ *.py[cod] .DS_Store
@@ -0,0 +1,287 @@
1
+ Metadata-Version: 2.4
2
+ Name: fmri_qctoolkit
3
+ Version: 1.0.0
4
+ Summary: MRI Quality Control Dashboard for AFNI and fMRIPrep pipelines
5
+ Author-email: Qiuyu Yu <qiuyuyu.psych@gmail.com>
6
+ Maintainer-email: Qiuyu Yu <qiuyuyu.psych@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/QiuyuYu3/fMRI-QCtoolkit
9
+ Project-URL: Repository, https://github.com/QiuyuYu3/fMRI-QCtoolkit
10
+ Project-URL: Issues, https://github.com/QiuyuYu3/fMRI-QCtoolkit/issues
11
+ Project-URL: Changelog, https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/CHANGELOG.md
12
+ Keywords: fMRI,quality control,MRIQC,fMRIPrep,AFNI,dashboard
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Framework :: Dash
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
23
+ Classifier: Topic :: Scientific/Engineering :: Visualization
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: typer>=0.16
28
+ Requires-Dist: dash<5,>=2.17
29
+ Requires-Dist: plotly>=5.20
30
+ Requires-Dist: pandas>=2.1
31
+ Requires-Dist: numpy>=1.26
32
+ Requires-Dist: flask>=3.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=6.0; extra == "dev"
35
+ Requires-Dist: pytest-cov; extra == "dev"
36
+ Requires-Dist: black; extra == "dev"
37
+ Requires-Dist: isort; extra == "dev"
38
+ Requires-Dist: flake8; extra == "dev"
39
+ Requires-Dist: ruff; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # fMRI-QCtoolkit
43
+
44
+ fMRI-QCtoolkit is a modular Python package for fMRI (functional Magnetic Resonance Imaging) quality control (QC), integrating quantitative metrics from [MRIQC](https://mriqc.readthedocs.io/en/latest/), [fMRIPrep](https://fmriprep.org/en/stable/), and [AFNI](https://afni.nimh.nih.gov/), along with manual scoring. The package includes an interactive dashboard with customizable filters and visualizations, a lightweight front-end for manual rating for fMRIPrep, and supports batch-level scoring for both fMRIPrep and AFNI outputs.
45
+
46
+ ![workflow](https://raw.githubusercontent.com/QiuyuYu3/fMRI-QCtoolkit/main/images/workflow.png)
47
+
48
+ ## Install
49
+ Python 3.11 or newer is required. Create or activate a virtual environment, then install from PyPI:
50
+
51
+ ```bash
52
+ pip install fmri-qctoolkit
53
+ ```
54
+
55
+ The example data used in the commands below is not part of the PyPI package. To run the examples, or to work on the code, clone the repository and install it in development mode:
56
+
57
+ ```bash
58
+ git clone https://github.com/QiuyuYu3/fMRI-QCtoolkit.git
59
+ cd fMRI-QCtoolkit
60
+ pip install -e .[dev]
61
+ ```
62
+
63
+ # Usage
64
+
65
+ ## STEP1: Rating
66
+
67
+ After the completion of preprocessing, perform qualitative scoring on the derivatives.
68
+
69
+ ### AFNI
70
+ AFNI provides [scripts](https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/tutorials/apqc_html/browsing.html#using-a-script-to-load-many-apqc-html-files) for browsing multiple subjects' QC files. However, using `firefox` on HPC (High-performance computing) systems may result in issues interacting with buttons, so this using `open_apqc.py` is another option (while ensuring the required Python packages are activated in the environment).
71
+
72
+ The directory structure of AFNI derivatives is as follows:
73
+ ```
74
+ .
75
+ └── AFNI_derivatives/
76
+ ├── sub-001/
77
+ │ └── ses-01/
78
+ │ └── cards_output/
79
+ │ └── sub-001.results/
80
+ │ ├── QC_sub-001
81
+ │ └── ...
82
+ ├── sub-002
83
+ ├── sub-003
84
+ └── ...
85
+ ```
86
+
87
+ **Input Arguments:**
88
+ - `fmriqc rating afni`: Indicate which rating program.
89
+ - `--input-dir`: Root directory, containing results that preprocessed from different participants.
90
+ - `--subjects`: Support input multiple participants IDs.
91
+ - `--task`: Rating program will search `task` in `input-dir` to find the `QC_{subj}`
92
+ - `--prefix`: The prefix of participants IDs.
93
+
94
+ **Example Synatx:**
95
+ ```bash
96
+ fmriqc rating afni --input-dir /PATH/AFNI_derivatives --subjects "003,009" --task ses-01/cards --prefix sub-
97
+ ```
98
+
99
+ *Although I've tried to make the scoring criteria flexible, it may still not support all pathfinding scenarios. Therefore, you can also try [script version](https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/examples/scripts/rating/afni_rating.sh).*
100
+
101
+ > [!IMPORTANT]
102
+ > The rating program relies on the `open_apqc.py` tool developed by AFNI.
103
+ > You can either:
104
+ > - Make sure `open_apqc.py` is on your `$PATH` (e.g., load the AFNI module first), or
105
+ > - Provide a custom path using the `--afni-path` option when running the command.
106
+ > `fmriqc rating afni --input-dir /PATH/AFNI_derivatives --subjects "003,009" --task ses-01/cards --prefix sub- --afni-path /PATH`
107
+
108
+ ![AFNI_rating](https://raw.githubusercontent.com/QiuyuYu3/fMRI-QCtoolkit/main/images/AFNI_rating.png)
109
+
110
+ ### fMRIPrep
111
+ The rating module in **fMRI-QCtoolkit** is based on the HTML reports generated by fMRIPrep (e.g., `sub-{ID}.html`).
112
+ Each QC item maps directly to specific sections of the original [fMRIPrep report](https://fmriprep.org/en/stable/_static/SampleReport/sample_report.html).
113
+
114
+ - Brain mask and brain tissue segmentation of the T1w (T1mask)
115
+ - Spatial normalization of the anatomical T1w reference (Norm)
116
+ - Surface reconstruction (SurfRecon)
117
+ - Susceptibility distortion correction (SDC)
118
+ - Alignment of functional and anatomical MRI data (coregistration) (Align)
119
+ - Brain mask and (anatomical/temporal) CompCor ROIs (CompCor)
120
+ - Variance explained by t/aCompCor components (Variance)
121
+ - BOLD Summary (BOLD)
122
+ - Correlations among nuisance regressors (Corr)
123
+
124
+ The interface is divided into two parts:
125
+ - **Upper panel**: navigate modules with a left-click; scroll horizontally with the mouse wheel.
126
+ - **Lower panel**: interactive rating area, similar to [AFNI’s APQC HTML](https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/tutorials/apqc_html/main_toc.html).
127
+ - Left-click to rate, Ctrl+click to add comments.
128
+ - Rating buttons toggle between: good (+, green), bad (×, red), and other (?, yellow).
129
+ - Results are saved automatically as CSV files (subject-level and task-level). Upon reopening the program with the same code, it will automatically retrieve the previous scores by extracting the subject-level CSV file.
130
+
131
+ > [!IMPORTANT]
132
+ > If the program cannot detect the session and run number, both will default to 1. For example, the saved CSV file name would be `sub-{ID}_ses-01_rest.csv`. Therefore, when merging with files generated by MRIQC, you need to modify the `ses` parameters.
133
+
134
+ > [!IMPORTANT]
135
+ > For multi-session subjects, fMRIPrep merges all T1w images into a single anatomical reference ([longitudinal processing](https://fmriprep.org/en/stable/workflows.html#longitudinal-processing)). T1mask / Norm / SurfRecon therefore describe that merged image: one rating per subject, not per session. If several images appear under one of these headings, the subject was processed more than once; check the `Get figure file:` line and rate the one from your current run.
136
+
137
+ The directory structure of fMRIPrep derivatives is as follows:
138
+ ```
139
+ .
140
+ └── fMRIPrep_derivatives/
141
+ ├── sub-001
142
+ ├── sub-001.html
143
+ ├── sub-002
144
+ ├── sub-002.html
145
+ ├── sub-003
146
+ ├── sub-003.html
147
+ ├── dataset_description.json
148
+ ├── desc-aparcaseg_dseg.tsv
149
+ ├── desc-aseg_dseg.tsv
150
+ └── ...
151
+ ```
152
+
153
+ **Input Arguments:**
154
+ - `fmriqc rating fmriprep`: Indicate which rating program.
155
+ - `--input-dir`: Root directory, containing results that preprocessed from different participants.
156
+ - `--subjects`: Support input multiple participants IDs.
157
+ - `--output-dir`: Path for exporting the scoring CSV file.
158
+ - `--no-browser`: Only print the links, without opening browser tabs (useful on HPC; see [Access Links](#access-links)).
159
+
160
+ **Example Synatx:**
161
+ ```bash
162
+ fmriqc rating fmriprep --input-dir /PATH/fMRIPrep_derivatives --output-dir /PATH/Output_dir --subjects "1013,1026"
163
+ ```
164
+
165
+ ![fMRIPrep_rating](https://raw.githubusercontent.com/QiuyuYu3/fMRI-QCtoolkit/main/images/fMRIPrep_rating.png)
166
+
167
+ ## STEP2: Data Preparation
168
+ By extracting information from qualitative rating files, `fmriqc prep` program then generates two dataframes to put into the dashboard.
169
+
170
+ ### AFNI
171
+ After finishing preprocessing and rating, both quantitative and qualitative rating information are saved in `QC_{subj}/extra_info/out.ss_review.{subj}.json`.
172
+
173
+ **Input Arguments:**
174
+ - `fmriqc prep afni`: Indicate which rating program.
175
+ - `--input-dir`: Root directory, containing results that preprocessed from different participants.
176
+ - `--output-dir`: Path for exporting `df_final.csv` and `lollipop_chart_data.csv` files.
177
+ - `--task`: Prep program will search `task` in `input-dir` to find the `QC_{subj}/extra_info/out.ss_review.{subj}.json` across all participants. Each run covers one session: if a subject matches in more than one place (for example `ses-01/rest_output` and `ses-02/rest_output`), narrow `--task` to `ses-01/rest`.
178
+ - `--prefix`: The prefix of participants IDs.
179
+
180
+ **Example Synatx:**
181
+ ```bash
182
+ fmriqc prep afni --input-dir /PATH/AFNI_derivatives --task ses-01/kidvid --output-dir /PATH/Output_dir --prefix sub-
183
+ ```
184
+
185
+ > [!NOTE]
186
+ > The quantitative parameters are extracted and coded according to the following [standards](https://www.frontiersin.org/files/Articles/1073800/fnins-16-1073800-HTML/image_m/fnins-16-1073800-t001.jpg). Users may also modify [JSON file](https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/fMRI_QCtoolkit/dashboard/afni_config.json) and [status file](https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/fMRI_QCtoolkit/utils/status.py) based on their own requirements.
187
+
188
+ ### fMRIPrep
189
+
190
+ After finishing rating procedure, merge the qualitative rating files with quantitative file (`group_bold.tsv`) that generates by MRIQC, and output two dataframes to put into dashboard.
191
+
192
+ **Input Arguments:**
193
+ - `fmriqc prep fmriprep`: Indicate which rating program.
194
+ - `--bold-file`: Input `group_bold.tsv` file that generated by MRIQC.
195
+ - `--rating-dir`: Path for storing fMRIPrep qualitative scores.
196
+ - `--task`: Indicate which task's rating data you want to use.
197
+ - `--output-dir`: Path for exporting `df_final.csv` and `lollipop_chart_data.csv` files.
198
+
199
+ **Example Synatx:**
200
+ ```bash
201
+ fmriqc prep fmriprep --bold-file examples/example_data/fmriprep/group_bold.tsv --rating-dir examples/example_data/fmriprep/ --task rest --output-dir examples/example_data/fmriprep/
202
+ ```
203
+
204
+ > [!NOTE]
205
+ > The quantitative parameters are extracted from [here](https://mriqc.readthedocs.io/en/latest/iqms/bold.html) and coded according to the following [standards](https://www.frontiersin.org/files/Articles/1073800/fnins-16-1073800-HTML/image_m/fnins-16-1073800-t001.jpg). Users may also modify [JSON file](https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/fMRI_QCtoolkit/dashboard/fmriprep_config.json) and [status file](https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/fMRI_QCtoolkit/utils/status.py) based on their own requirements.
206
+
207
+ ### STEP3: Viewing and Filtering Results via Dashboard
208
+ Visualize, filter, and export selected data.
209
+
210
+ The left side of the dashboard features filter sidebars where users can select the desired ranges. The two central tabs display data tables and visualizations (heatmaps and lollipop charts). After selecting rows in the data table, the blue download button below allows exporting the corresponding data frame.
211
+
212
+ ![dashboard1](https://raw.githubusercontent.com/QiuyuYu3/fMRI-QCtoolkit/main/images/dashboard1.png)
213
+ ![dashboard2](https://raw.githubusercontent.com/QiuyuYu3/fMRI-QCtoolkit/main/images/dashboard2.png)
214
+ ![dashboard3](https://raw.githubusercontent.com/QiuyuYu3/fMRI-QCtoolkit/main/images/dashboard3.png)
215
+
216
+ ### AFNI
217
+
218
+ **Input Arguments:**
219
+ - `fmriqc dashboard afni`: Indicate which rating program.
220
+ - `--data-file`: Input the merged dataframe.
221
+ - `--lollipop-file`: Input the data for lollipop chart.
222
+ - `--task`: Specify the task name to be used when downloading data.
223
+
224
+ **Example Synatx:**
225
+ ```bash
226
+ fmriqc dashboard afni --data-file /PATH/Output_dir/df_final.csv --lollipop-file /PATH/Output_dir/lollipop_chart_data.csv --task kidvid
227
+ ```
228
+
229
+ ### fMRIPrep
230
+
231
+ **Input Arguments:**
232
+ - `fmriqc dashboard fmriprep`: Indicate which rating program.
233
+ - `--data-file`: Input the merged dataframe.
234
+ - `--lollipop-file`: Input the data for lollipop chart.
235
+ - `--task`: Specify the task name to be used when downloading data and filtering task in the merged dataframe.
236
+
237
+ **Example Synatx:**
238
+ ```bash
239
+ fmriqc dashboard fmriprep --data-file examples/example_data/fmriprep/df_final.csv --lollipop-file examples/example_data/fmriprep/lollipop_chart_data.csv --task rest
240
+ ```
241
+
242
+ # Access Links
243
+ `fmriqc rating fmriprep` and `fmriqc dashboard` start a local web server that only answers requests carrying a session token. The terminal prints one link per subject (or one for the dashboard), for example:
244
+
245
+ ```
246
+ INFO - http://localhost:5003/0030?token=Xk3v9QpL2mR7tYwZ8aBcD1eF4gH6jK0n
247
+ ```
248
+
249
+ On your own computer, the rating tabs open automatically. Otherwise, click or paste the printed link. After the first visit, the token is kept in a browser cookie and dropped from the address bar. A new token is created every time the server starts, so after a restart (or after closing the browser) use the newly printed link. An "Access denied" page means the link is missing or out of date.
250
+
251
+ **Running on HPC.** Start the server on the cluster with `--no-browser`, then forward its port from your own computer and open the printed link there:
252
+
253
+ ```bash
254
+ # Server on the login node
255
+ ssh -N -L 5003:127.0.0.1:5003 user@hpc.example.edu
256
+ # Server on a compute node (e.g. node123 inside an srun/salloc session)
257
+ ssh -N -L 5003:127.0.0.1:5003 -J user@hpc.example.edu user@node123
258
+ ```
259
+
260
+ The local port may differ from the remote one (`-L 8888:127.0.0.1:5003`); change the port in the link accordingly and keep the token. Other users on the same node cannot open the pages without the token.
261
+
262
+ `fmriqc dashboard --host` can bind to a non-loopback address, in which case the token is the only protection. With `--host 0.0.0.0` the printed link uses this machine's hostname. `--debug` is refused on such a host.
263
+
264
+ # [Training Materials](https://github.com/QiuyuYu3/fMRI-QCtoolkit/tree/main/training_materials)
265
+ We have summarized the AFNI QC training documentation based on existing literature and included several case studies (still under revision).
266
+
267
+ # Summary
268
+
269
+ > [!NOTE]
270
+ > - The data prep feature is designed for users unfamiliar with Python. If you want more flexible data wrangling, try the scripts (or write your scripts).
271
+ > - The sidebar and visualizations are highly customizable, as long as the input dataframe contains the corresponding data. By configuring [AFNI](https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/fMRI_QCtoolkit/dashboard/afni_config.json) and [fMRIPrep](https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/fMRI_QCtoolkit/dashboard/fmriprep_config.json) config files, as well as [asign status to variables](https://github.com/QiuyuYu3/fMRI-QCtoolkit/blob/main/fMRI_QCtoolkit/utils/status.py), users can customize filters and the items displayed in visualizations.
272
+
273
+ # Citation
274
+ Coming soon!
275
+
276
+ ## Reference
277
+ - Cox R. W. (1996). AFNI: software for analysis and visualization of functional magnetic resonance neuroimages. Computers and biomedical research, an international journal, 29(3), 162–173. https://doi.org/10.1006/cbmr.1996.0014
278
+ - Cox, R. W., & Hyde, J. S. (1997). Software tools for analysis and visualization of fMRI data. NMR in biomedicine, 10(4-5), 171–178. https://pubmed.ncbi.nlm.nih.gov/9430344/
279
+ - Esteban, O., Birman, D., Schaer, M., Koyejo, O. O., Poldrack, R. A., & Gorgolewski, K. J. (2017). MRIQC: Advancing the automatic prediction of image quality in MRI from unseen sites. PloS one, 12(9), e0184661. https://doi.org/10.1371/journal.pone.0184661
280
+ - Esteban, O., Ciric, R., Finc, K. et al. Analysis of task-based functional MRI data preprocessed with fMRIPrep. Nat Protoc 15, 2186–2202 (2020). https://doi.org/10.1038/s41596-020-0327-3
281
+ - Harris, C.R., Millman, K.J., van der Walt, S.J. et al. Array programming with NumPy. Nature 585, 357–362 (2020). https://doi.org/10.1038/s41586-020-2649-2
282
+ - Kruchten, N., Seier, A., & Parmer, C. (2025). An interactive, open-source, and browser-based graphing library for Python (Version 6.3.1) [Computer software]. https://doi.org/10.5281/zenodo.14503524
283
+ - Pallets. (2025). Flask (Version 3.1.1) [Computer software]. PyPI. https://palletsprojects.com/
284
+ - Parmer, C., Duval, P., & Johnson, A. (2025). A data and analytics web app framework for Python, no JavaScript required. (Version 3.2.0) [Computer software]. https://doi.org/10.5281/zenodo.14182630
285
+ - Ramírez, S. (2025). Typer (Version 0.19.2) [Computer software]. https://github.com/fastapi/typer
286
+ - Reynolds, R. C., Taylor, P. A., & Glen, D. R. (2023). Quality control practices in FMRI analysis: Philosophy, methods and examples using AFNI. Frontiers in Neuroscience, 16, 1073800. https://doi.org/10.3389/fnins.2022.1073800
287
+ - The pandas development team. pandas-dev/pandas: Pandas [Computer software]. https://doi.org/10.5281/zenodo.3509134