Skip to content

Commit

Permalink
Merge branch 'master' into TreatWarningsAsErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban authored Jan 15, 2025
2 parents 5e887db + f5040a3 commit f91c8dd
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 117 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ jobs:
deploy_pypi:
docker:
- image: cimg/python:3.8.5
- image: cimg/python:3.10
working_directory: /tmp/src/mriqc
steps:
- checkout
Expand Down Expand Up @@ -725,7 +725,7 @@ jobs:
deploy_docker:
machine:
image: ubuntu-2004:202104-01
image: default
working_directory: /tmp/src/mriqc
steps:
- restore_cache:
Expand Down
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Ross Blair <[email protected]> <[email protected]>
Teresa Gomez <[email protected]>
Teresa Gomez <[email protected]> teresamg
Yibei Chen <[email protected]>
Victor Férat <[email protected]>
Victor Férat <[email protected]> vferat
William Triplett <[email protected]>
Zvi Baratz <[email protected]>
Zvi Baratz <[email protected]> ZviBaratz
Expand Down
1 change: 1 addition & 0 deletions .maint/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Before every release, unlisted contributors will be invited again to add their n
| Durnez | Joke | @jokedurnez | 0000-0001-9030-2202 | Department of Psychology, Stanford University, CA, USA |
| Erramuzpe | Asier | @erramuzpe | 0000-0002-9402-2184 | Computational Neuroimaging Lab, BioCruces Health Research Institute |
| Fauber | Bennet | @justbennet | | University of Michigan, Ann Arbor, USA |
| Férat | Victor | @vferat | 0000-0003-1952-7657 | Department of Basic Neurosciences, Université de Genève, Geneva, Switzerland |
| Garcia-Dias | Rafael | @garciadias | 0000-0001-9332-1580 | Institute of Psychiatry, Psychology & Neuroscience, King's College London, London, UK |
| Ghosh | Satrajit S. | @satra | 0000-0002-5312-6729 | McGovern Institute for Brain Research, MIT, MA, USA; and Department of Otolaryngology, Harvard Medical School, MA, USA |
| Gomez | Teresa | @teresamg | | The University of Washington eScience Institute, WA, USA |
Expand Down
14 changes: 6 additions & 8 deletions .maint/update_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_git_lines(fname='line-contributors.txt'):

git_line_summary_path = shutil.which('git-line-summary')
if not git_line_summary_path:
git_line_summary_path = "git summary --dedup-by-email".split(" ")
git_line_summary_path = 'git summary --dedup-by-email'.split(' ')
else:
git_line_summary_path = [git_line_summary_path]

Expand Down Expand Up @@ -233,7 +233,7 @@ def zenodo(
creator['affiliation'] = creator['affiliation'][0]

Path(zenodo_file).write_text(
'%s\n' % json.dumps(zenodo, indent=2)
f'{json.dumps(zenodo, indent=2)}\n'
)


Expand Down Expand Up @@ -301,20 +301,18 @@ def _aslist(value):

print('Authors (%d):' % len(hits))
print(
'%s.'
% '; '.join(
'{}.'.format('; '.join(
[
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
for i, idx in zip(hits, aff_indexes)
]
)
))
)

print(
'\n\nAffiliations:\n%s'
% '\n'.join(
'\n\nAffiliations:\n{}'.format('\n'.join(
[f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)]
)
))
)


Expand Down
24 changes: 12 additions & 12 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
"name": "John A. Lee",
"type": "Researcher"
},
{
"orcid": "0000-0002-9661-1396",
"affiliation": "Brigham and Women's Hospital, Mass General Brigham, Harvard Medical School, MA, USA",
"name": "Jon Haitz Legarreta Gorro\u00f1o",
"type": "Researcher"
},
{
"orcid": "0000-0003-4141-1343",
"affiliation": "Johns Hopkins Bloomberg School of Public Health, MD, USA",
Expand All @@ -104,6 +110,12 @@
"name": "Ursula A. Tooley",
"type": "Researcher"
},
{
"orcid": "0000-0003-3456-2493",
"affiliation": "Psychological and Brain Sciences Department, Dartmouth College, NH, USA",
"name": "Yaroslav O. Halchenko",
"type": "Researcher"
},
{
"orcid": "0000-0003-2882-0900",
"affiliation": "McGovern Institute for Brain Research, Massachusetts Institute of Technology, Cambridge, USA",
Expand All @@ -116,12 +128,6 @@
"name": "James D. Kent",
"type": "Researcher"
},
{
"orcid": "0000-0003-3456-2493",
"affiliation": "Psychological and Brain Sciences Department, Dartmouth College, NH, USA",
"name": "Yaroslav O. Halchenko",
"type": "Researcher"
},
{
"affiliation": "University of Michigan, Ann Arbor, USA",
"name": "Bennet Fauber",
Expand All @@ -133,12 +139,6 @@
"name": "Taylor Salo",
"type": "Researcher"
},
{
"orcid": "0000-0002-9661-1396",
"affiliation": "Brigham and Women's Hospital, Mass General Brigham, Harvard Medical School, MA, USA",
"name": "Jon Haitz Legarreta Gorro\u00f1o",
"type": "Researcher"
},
{
"affiliation": "Max Planck Institute for Human Development, Berlin, Germany",
"name": "Michael Krause",
Expand Down
17 changes: 17 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
25.0.0 (TBD)
============
A new 25.x series.

CHANGES
-------
* FIX: Decode bytes to produce a string (#1371)
* FIX: Containers report wrong version (#1357)
* FIX: Elapsed run time format (#1366)
* FIX: Passing ``bytes`` into ``str.join()`` (#1356)
* FIX: Optimize interface to minimize memory fingerprint (#1351)
* ENH: Remove redundant *DIPY* function (#1369)
* DOC: Add a HPC troubleshooting section to the documentation (#1349)
* DOC: Provide a range of years ending with current for the copyright statement (#1359)
* DOC: Fix missing code block start (#1368)
* DOC: Reorganize documentation and redirect to *NiPreps* docs (#1367)

24.0.2 (August 26, 2024)
========================
A patch release with bugfixes and enhancements.
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ FROM python:slim AS src
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends git
ARG VERSION
ENV SETUPTOOLS_SCM_PRETEND_VERSION=$VERSION

RUN python -m pip install -U pip build
COPY . /src
RUN python -m build /src
Expand Down Expand Up @@ -197,11 +200,14 @@ RUN find $HOME -type d -exec chmod go=u {} + && \
# Best practices
RUN ldconfig

# Update version
RUN export VERSION=$(python -m mriqc --version | awk '{print $NF}') \
&& echo "VERSION=$VERSION" >> /etc/environment

WORKDIR /tmp/

# Run mriqc by default
ENTRYPOINT ["/opt/conda/bin/mriqc"]
ARG VERSION
ARG BUILD_DATE
ARG VCS_REF
LABEL org.label-schema.build-date=$BUILD_DATE \
Expand Down
98 changes: 32 additions & 66 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Before moving forward, please make sure to have read and understood
`introductory documentation <https://www.nipreps.org/apps/framework/>`__).

Containerized execution with *Docker* and *Singularity*/*Apptainer*
-------------------------------------------------------
-------------------------------------------------------------------
For containerized execution with *Docker* or *Singularity*/*Apptainer*, please
follow the documentation on the *NiPreps* site, which contains
tip and troubleshooting guidelines for both
Expand All @@ -24,6 +24,30 @@ also includes specific
The rest of this documentation page applies to both *bare-metal*
and containerized execution modes.

*MRIQC* can fetch data in *DataLad* datasets
--------------------------------------------
As of version 22.0.3, *MRIQC* bundles *DataLad*, enabling automatic
data fetching in *DataLad* datasets.
Employing this feature in containerized environments may lead to
somewhat obscure errors (see, for example,
`nipreps/mriqc#1307 <https://github.com/nipreps/mriqc/issues/1307>`__).
If you intend to use *DataLad* datasets, please read carefully
*NiPreps*' `help for processing DataLad-managed datasets <https://www.nipreps.org/apps/datalad/>`__.

Alternatively, this feature can be disabled by adding
``--no-datalad-get`` to the command line.
This will separate *DataLad* management from *MRIQC*'s operation,
which can be an effective way of debugging issues and averting
erroneous conditions.

Troubleshooting
---------------
If you encounter problems, please check our
`NiPreps Guidelines for Singularity or Apptainer <https://www.nipreps.org/apps/singularity/>`__.
Common tips and guidelines that used to be found within *MRIQC*'s
or *fMRIPrep*'s documentation sites have been relocated in the
general *NiPreps* website.

A *BIDS Apps* command line interface
------------------------------------
*MRIQC* follows the *BIDS Apps* standard command line interface::
Expand Down Expand Up @@ -86,21 +110,13 @@ in :ref:`The MRIQC Reports <reports>`.
In the ``group`` level, the :abbr:`IQMs (image quality metrics)` extracted in
first place are combined in a table and the group reports are generated.

*MRIQC* can fetch data in *DataLad* datasets
--------------------------------------------
As of version 22.0.3, *MRIQC* bundles *DataLad*, enabling automatic
data fetching in *DataLad* datasets.
Employing this feature in containerized environments may lead to
somewhat obscure errors (see, for example,
`nipreps/mriqc#1307 <https://github.com/nipreps/mriqc/issues/1307>`__).
If you intend to use *DataLad* datasets, please read carefully
*NiPreps*' `help for processing DataLad-managed datasets <https://www.nipreps.org/apps/datalad/>`__.

Alternatively, this feature can be disabled by adding
``--no-datalad-get`` to the command line.
This will separate *DataLad* management from *MRIQC*'s operation,
which can be an effective way of debugging issues and averting
erroneous conditions.
Command line interface
......................
.. argparse::
:ref: mriqc.cli.parser._build_parser
:prog: mriqc
:nodefault:
:nodefaultconst:

Running *MRIQC* on HPC with *Singularity*/*Apptainer*
-----------------------------------------------------
Expand Down Expand Up @@ -131,56 +147,6 @@ on ds030 of OpenfMRI:
maximum of 10GB. Since we saw a memory consumption of 1-2GB during the
the 1-task example, a rule of thumb may be that each task takes around
1GB of memory.

Known issues with HPC
.....................

#. No internet access

The container needs to download the templates from the internet.
If the container does not have internet access, you can download the
templates manually using the ``templateflow`` library:

.. code-block:: python
import templateflow.api
templateflow.api.TF_S3_ROOT = 'http://templateflow.s3.amazonaws.com'
templateflow.api.get('MNI152NLin2009cAsym') # change template if needed
then provide the templates to the container by mounting the ``templateflow`` home directory and setting the ``TEMPLATEFLOW_HOME`` environment variable:

.. code-block:: bash
apptainer run -v /path/to/templateflow:/path/to/templates --env TEMPLATEFLOW_HOME=/path/to/templates ...
#. Socket error:

When running multiple instances of MRIQC on a HPC, you may encounter the following error:

.. code-block:: python
OSError: [Errno 98] Address already in use
To solve this issue, you can try to isolate the container network from the host network by using the ``--network none`` option.

.. code-block:: bash
apptainer run --net --network none ...
This solution might prevent the container from accessing the internet and downloading templates.
In this case, you can download the templates manually and provide access to the downloaded files as explained in the previous section.

.. code-block:: bash
apptainer run --net --network none -v /path/to/templateflow:/path/to/templates --env TEMPLATEFLOW_HOME=/path/to/templates ...
Command line interface
----------------------
.. argparse::
:ref: mriqc.cli.parser._build_parser
:prog: mriqc
:nodefault:
:nodefaultconst:

.. topic:: References

Expand Down
2 changes: 1 addition & 1 deletion mriqc/bin/abide2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def fetch(args: (str, str, str, str)) -> (str, str):
out_dir = op.abspath(out_dir)

pkg_id = [u[9:] for u in url.split('/') if u.startswith('NITRC_IR_')][0]
sub_file = op.join(tmpdir, '%s.zip' % pkg_id)
sub_file = op.join(tmpdir, f'{pkg_id}.zip')

cmd = [_curl_cmd, '-s', '-u', f'{user}:{password}', '-o', sub_file, url]
sp.check_call(cmd)
Expand Down
16 changes: 8 additions & 8 deletions mriqc/bin/fs2gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ def main():
center = np.average([bbox_min, bbox_max], axis=0)

if opts.hist_eq:
ref_file = op.join(tmp_sub, '%s.mgz' % subid)
ref_file = op.join(tmp_sub, f'{subid}.mgz')
img = nb.load(op.join(sub_path, 'mri', 'norm.mgz'))
data = exposure.equalize_adapthist(img.get_fdata(), clip_limit=0.03)
nb.MGHImage(data, img.affine, img.header).to_filename(ref_file)

if not opts.zoom:
# Export tiffs for left hemisphere
tcl_file = op.join(tmp_sub, '%s.tcl' % subid)
tcl_file = op.join(tmp_sub, f'{subid}.tcl')
with open(tcl_file, 'w') as tclfp:
tclfp.write(tcl_contents)
tclfp.write(
Expand All @@ -147,7 +147,7 @@ def main():
if opts.use_xvfb:
cmd = _xvfb_run() + cmd

print('Running tkmedit: %s' % ' '.join(cmd))
print('Running tkmedit: {}'.format(' '.join(cmd)))
sp.call(cmd, env=environ)
# Convert to animated gif
print('Stacking coronal slices')
Expand All @@ -165,7 +165,7 @@ def main():

else:
# Export tiffs for left hemisphere
tcl_file = op.join(tmp_sub, 'lh-%s.tcl' % subid)
tcl_file = op.join(tmp_sub, f'lh-{subid}.tcl')
with open(tcl_file, 'w') as tclfp:
tclfp.write(tcl_contents)
tclfp.write('SetZoomLevel 2')
Expand All @@ -184,13 +184,13 @@ def main():
if opts.use_xvfb:
cmd = _xvfb_run() + cmd

print('Running tkmedit: %s' % ' '.join(cmd))
print('Running tkmedit: {}'.format(' '.join(cmd)))
sp.call(cmd, env=environ)
# Convert to animated gif
print('Stacking coronal slices')

# Export tiffs for right hemisphere
tcl_file = op.join(tmp_sub, 'rh-%s.tcl' % subid)
tcl_file = op.join(tmp_sub, f'rh-{subid}.tcl')
with open(tcl_file, 'w') as tclfp:
tclfp.write(tcl_contents)
tclfp.write('SetZoomLevel 2')
Expand All @@ -209,7 +209,7 @@ def main():
if opts.use_xvfb:
cmd = _xvfb_run() + cmd

print('Running tkmedit: %s' % ' '.join(cmd))
print('Running tkmedit: {}'.format(' '.join(cmd)))
sp.call(cmd, env=environ)
# Convert to animated gif
print('Stacking coronal slices')
Expand Down Expand Up @@ -260,7 +260,7 @@ def _xvfb_run(wait=5, server_args='-screen 0, 1600x1200x24', logs=None):


def _myerror(msg):
print('WARNING: Error deleting temporal files: %s' % msg)
print(f'WARNING: Error deleting temporal files: {msg}')


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion mriqc/bin/labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def main():
finished[j - 1] = finished[j - 1] + 1
hold[j - 1, i - 1] = int(file[i][j])
finished = np.divide(np.round(np.divide(finished, total) * 1000), 10)
print(f'Completed: {" ".join(["%g%%" % f for f in finished])}')
print(f'Completed: {" ".join([f"{f:g}%" for f in finished])}')
print(f'Total: {np.round(np.divide(np.sum(finished), 3))}%')
input('Waiting: [enter]')

Expand Down
Loading

0 comments on commit f91c8dd

Please sign in to comment.