diff --git a/README.md b/README.md index 43150b113..4498fcc22 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ ![PyPI - Wheel](https://img.shields.io/pypi/wheel/junifer?style=flat-square) ![GitHub](https://img.shields.io/github/license/juaml/junifer?style=flat-square) ![Codecov](https://img.shields.io/codecov/c/github/juaml/junifer?style=flat-square) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black) ## About diff --git a/docs/builtin.rst b/docs/builtin.rst index 2ec046296..5b917706e 100644 --- a/docs/builtin.rst +++ b/docs/builtin.rst @@ -43,55 +43,55 @@ Available - Type/Config - State - Version Added - * - :class:`junifer.datagrabber.DataladHCP1200` + * - :class:`.DataladHCP1200` - `HCP OpenAccess dataset `_ - Open with registration - Built-in - Done - 0.0.1 - * - :class:`junifer.configs.juseless.datagrabbers.JuselessDataladUKBVBM` + * - :class:`.JuselessDataladUKBVBM` - UKB VBM dataset preprocessed with CAT. Available for Juseless only. - Restricted - ``junifer.configs.juseless`` - Done - 0.0.1 - * - :class:`junifer.configs.juseless.datagrabbers.JuselessDataladCamCANVBM` + * - :class:`.JuselessDataladCamCANVBM` - CamCAN VBM dataset preprocessed with CAT. Available for Juseless only. - Restricted - ``junifer.configs.juseless`` - Done - 0.0.1 - * - :class:`junifer.datagrabber.DataladAOMICID1000` + * - :class:`.DataladAOMICID1000` - `AOMIC 1000 dataset `_ - Open without registration - Built-in - Done - 0.0.1 - * - :class:`junifer.datagrabber.DataladAOMICPIOP1` + * - :class:`.DataladAOMICPIOP1` - `AOMIC PIOP1 dataset `_ - Open without registration - Built-in - Done - 0.0.1 - * - :class:`junifer.datagrabber.DataladAOMICPIOP2` + * - :class:`.DataladAOMICPIOP2` - `AOMIC PIOP2 dataset `_ - Open without registration - Built-in - Done - 0.0.1 - * - :class:`junifer.configs.juseless.datagrabbers.JuselessDataladAOMICID1000VBM` + * - :class:`.JuselessDataladAOMICID1000VBM` - AOMIC ID1000 VBM dataset. Available for Juseless only. - Restricted - ``junifer.configs.juseless`` - Done - 0.0.1 - * - :class:`junifer.configs.juseless.datagrabbers.JuselessDataladIXIVBM` + * - :class:`.JuselessDataladIXIVBM` - `IXI VBM dataset `_. Available for Juseless only. - Restricted - ``junifer.configs.juseless`` - Done - 0.0.1 - * - :class:`junifer.configs.juseless.datagrabbers.JuselessUCLA` + * - :class:`.JuselessUCLA` - UCLA fMRIPrep dataset. Available for Juseless only. - Restricted - ``junifer.configs.juseless`` @@ -144,61 +144,61 @@ Available - Description - State - Version Added - * - :class:`junifer.markers.ParcelAggregation` + * - :class:`.ParcelAggregation` - Apply parcellation and perform aggregation function - Done - 0.0.1 - * - :class:`junifer.markers.FunctionalConnectivityParcels` + * - :class:`.FunctionalConnectivityParcels` - Compute functional connectivity over parcellation - Done - 0.0.1 - * - :class:`junifer.markers.CrossParcellationFC` + * - :class:`.CrossParcellationFC` - Compute functional connectivity across two parcellations - Done - 0.0.1 - * - :class:`junifer.markers.SphereAggregation` + * - :class:`.SphereAggregation` - Spherical aggregation using mean - Done - 0.0.1 - * - :class:`junifer.markers.FunctionalConnectivitySpheres` + * - :class:`.FunctionalConnectivitySpheres` - Compute functional connectivity over spheres placed on coordinates - Done - 0.0.1 - * - :class:`junifer.markers.RSSETSMarker` + * - :class:`.RSSETSMarker` - Compute root sum of squares of edgewise timeseries - Done - 0.0.1 - * - :class:`junifer.markers.ReHoParcels` + * - :class:`.ReHoParcels` - Calculate regional homogeneity over parcellation - Done - 0.0.1 - * - :class:`junifer.markers.ReHoSpheres` + * - :class:`.ReHoSpheres` - Calculate regional homogeneity over spheres placed on coordinates - Done - 0.0.1 - * - :class:`junifer.markers.ALFFParcels` + * - :class:`.ALFFParcels` - Calculate (f)ALFF and aggregate using parcellations - Done - 0.0.1 - * - :class:`junifer.markers.ALFFSpheres` + * - :class:`.ALFFSpheres` - Calculate (f)ALFF and aggregate using spheres placed on coordinates - Done - 0.0.1 - * - :class:`junifer.markers.EdgeCentricFCParcels` + * - :class:`.EdgeCentricFCParcels` - Calculate edge-centric functional connectivity over parcellation, as found in `Jo et al. (2021) `_ - Done - 0.0.2 - * - :class:`junifer.markers.EdgeCentricFCSpheres` + * - :class:`.EdgeCentricFCSpheres` - Calculate edge-centric functional connectivity over spheres placed on coordinates, as found in `Jo et al. (2021) `_ - Done - 0.0.2 - * - :class:`junifer.markers.TemporalSNRParcels` + * - :class:`.TemporalSNRParcels` - Calculate temporal signal-to-noise ratio using parcellations - Done - 0.0.2 - * - :class:`junifer.markers.TemporalSNRSpheres` + * - :class:`.TemporalSNRSpheres` - Calculate temporal signal-to-noise ratio using spheres placed on coordinates - Done - 0.0.2 diff --git a/docs/changes/newsfragments/146.feature b/docs/changes/newsfragments/146.feature index a81598ded..5f48fac7b 100644 --- a/docs/changes/newsfragments/146.feature +++ b/docs/changes/newsfragments/146.feature @@ -1 +1 @@ -Expose a :func:`junifer.data.parcellations.merge_parcellations` function to merge a list of parcellations by `Leonard Sasse`_ \ No newline at end of file +Expose a :func:`.merge_parcellations` function to merge a list of parcellations by `Leonard Sasse`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/147.feature b/docs/changes/newsfragments/147.feature index 6165f99c1..562701c7a 100644 --- a/docs/changes/newsfragments/147.feature +++ b/docs/changes/newsfragments/147.feature @@ -1 +1 @@ -Add support for HDF5 feature storage via :class:`junifer.storage.HDF5FeatureStorage` by `Synchon Mandal`_ \ No newline at end of file +Add support for HDF5 feature storage via :class:`.HDF5FeatureStorage` by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/158.change b/docs/changes/newsfragments/158.change index bb85b938a..de74f17af 100644 --- a/docs/changes/newsfragments/158.change +++ b/docs/changes/newsfragments/158.change @@ -1 +1 @@ -Add ``confounds_format`` parameter to :class:`junifer.datagrabber.PatternDataGrabber` constructor for improved handling of confounds specified via ``BOLD_confounds`` data type by `Synchon Mandal`_ \ No newline at end of file +Add ``confounds_format`` parameter to :class:`.PatternDataGrabber` constructor for improved handling of confounds specified via ``BOLD_confounds`` data type by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/160.enh b/docs/changes/newsfragments/160.enh index 0cb1334b9..270e188fd 100644 --- a/docs/changes/newsfragments/160.enh +++ b/docs/changes/newsfragments/160.enh @@ -1 +1 @@ -Allow :class:`junifer.testing.datagrabbers.PartlyCloudyTestingDataGrabber` to be accessible via ``import junifer.testing.registry`` by `Synchon Mandal`_ \ No newline at end of file +Allow :class:`.PartlyCloudyTestingDataGrabber` to be accessible via ``import junifer.testing.registry`` by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/163.feature b/docs/changes/newsfragments/163.feature index 7713815d5..73385163b 100644 --- a/docs/changes/newsfragments/163.feature +++ b/docs/changes/newsfragments/163.feature @@ -1 +1 @@ -Add :class:`junifer.markers.TemporalSNRParcels` and :class:`junifer.markers.TemporalSNRSpheres` by `Leonard Sasse`_ \ No newline at end of file +Add :class:`.TemporalSNRParcels` and :class:`.TemporalSNRSpheres` by `Leonard Sasse`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/183.bugfix b/docs/changes/newsfragments/183.bugfix deleted file mode 100644 index a2a0c7bb6..000000000 --- a/docs/changes/newsfragments/183.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix a bug in which only ``REST1`` and ``REST2`` tasks could be accesed in :class:`.DataladHCP1200` and :class:`.HCP1200` datagrabbers by `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/183.change b/docs/changes/newsfragments/183.change deleted file mode 100644 index 374b56acd..000000000 --- a/docs/changes/newsfragments/183.change +++ /dev/null @@ -1 +0,0 @@ -Add ``ica_fix`` parameter to :class:`.DataladHCP1200` and :class:`.HCP1200` datagrabbers to allow for selecting data processed with ICA+FIX. Default value is ``False`` which changes behaviour since 0.0.1 release. By `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/187.bugfix b/docs/changes/newsfragments/187.bugfix index 4c852e949..2cd330024 100644 --- a/docs/changes/newsfragments/187.bugfix +++ b/docs/changes/newsfragments/187.bugfix @@ -1 +1 @@ -Fix :class:`junifer.markers.ALFFParcels`, :class:`junifer.markers.ALFFSpheres`, :class:`junifer.markers.ReHoSpheres` and :class:`junifer.markers.ReHoParcels` pass the ``extra_input`` parameter by `Fede Raimondo`_ \ No newline at end of file +Fix :class:`.ALFFParcels`, :class:`.ALFFSpheres`, :class:`.ReHoSpheres` and :class:`.ReHoParcels` pass the ``extra_input`` parameter by `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/190.change b/docs/changes/newsfragments/190.change index fd3333b23..7c844e40d 100644 --- a/docs/changes/newsfragments/190.change +++ b/docs/changes/newsfragments/190.change @@ -1 +1 @@ -Expose ``allow_overlap`` parameter in :class:`junifer.markers.SphereAggregation` and related markers by `Fede Raimondo`_ \ No newline at end of file +Expose ``allow_overlap`` parameter in :class:`.SphereAggregation` and related markers by `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/190.enh b/docs/changes/newsfragments/190.enh index 0453d948a..24ebc90db 100644 --- a/docs/changes/newsfragments/190.enh +++ b/docs/changes/newsfragments/190.enh @@ -1 +1 @@ -Allow for empty spheres in :class:`junifer.external.nilearn.JuniferNiftiSpheresMasker`, that will result in NaNs. Also, modify the behaviour of the ``collect`` parameter in HTCondor ``queue`` function to run a collect job even if some of the previous jobs fail. This is useful to collect the results of a pipeline even if some of the jobs fail by `Fede Raimondo`_ \ No newline at end of file +Allow for empty spheres in :class:`.JuniferNiftiSpheresMasker`, that will result in NaNs. Also, modify the behaviour of the ``collect`` parameter in HTCondor ``queue`` function to run a collect job even if some of the previous jobs fail. This is useful to collect the results of a pipeline even if some of the jobs fail by `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/190.feature b/docs/changes/newsfragments/190.feature index 18386799f..0e2fc4aae 100644 --- a/docs/changes/newsfragments/190.feature +++ b/docs/changes/newsfragments/190.feature @@ -1 +1 @@ -Add aggregation function :func:`junifer.stats.count` that returns the number of elements in a given axis. This allows to count the number of voxels per sphere/parcel when used as ``method`` in markers by `Fede Raimondo`_ \ No newline at end of file +Add aggregation function :func:`.count` that returns the number of elements in a given axis. This allows to count the number of voxels per sphere/parcel when used as ``method`` in markers by `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/194.bugfix b/docs/changes/newsfragments/194.bugfix index 561bb0686..922eb87e5 100644 --- a/docs/changes/newsfragments/194.bugfix +++ b/docs/changes/newsfragments/194.bugfix @@ -1 +1 @@ -Fix a bug in which :class:`junifer.markers.ParcelAggregation` could yield duplicated column names if two or more parcels were used and label names were not unique by `Fede Raimondo`_ \ No newline at end of file +Fix a bug in which :class:`.ParcelAggregation` could yield duplicated column names if two or more parcels were used and label names were not unique by `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/194.enh b/docs/changes/newsfragments/194.enh index f4d4123b9..c821fc734 100644 --- a/docs/changes/newsfragments/194.enh +++ b/docs/changes/newsfragments/194.enh @@ -1 +1 @@ -Allow for empty parcels in :class:`junifer.markers.ParcelAggregation`, that will result in NaNs by `Fede Raimondo`_ \ No newline at end of file +Allow for empty parcels in :class:`.ParcelAggregation`, that will result in NaNs by `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/195.bugfix b/docs/changes/newsfragments/195.bugfix index f5bb6d7d6..8a89cc9da 100644 --- a/docs/changes/newsfragments/195.bugfix +++ b/docs/changes/newsfragments/195.bugfix @@ -1 +1 @@ -Fix a bug in which :func:`junifer.stats.count` will not be correctly applied across an axis by `Fede Raimondo`_ \ No newline at end of file +Fix a bug in which :func:`.count` will not be correctly applied across an axis by `Fede Raimondo`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/196.enh b/docs/changes/newsfragments/196.enh index 02b0a3c8d..afbe29424 100644 --- a/docs/changes/newsfragments/196.enh +++ b/docs/changes/newsfragments/196.enh @@ -1 +1 @@ -Improve metadata and data I/O for :class:`junifer.storage.HDF5FeatureStorage` by `Synchon Mandal`_ \ No newline at end of file +Improve metadata and data I/O for :class:`.HDF5FeatureStorage` by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/200.bugfix b/docs/changes/newsfragments/200.bugfix index f16beff4c..1785e3870 100644 --- a/docs/changes/newsfragments/200.bugfix +++ b/docs/changes/newsfragments/200.bugfix @@ -1 +1 @@ -Fix a bug in which :func:`junifer.data.masks.get_mask` fails for FunctionalConnectivityBase class, because of missing extra_input parameter by `Leonard Sasse`_ \ No newline at end of file +Fix a bug in which :func:`.get_mask` fails for FunctionalConnectivityBase class, because of missing extra_input parameter by `Leonard Sasse`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/214.enh b/docs/changes/newsfragments/214.enh index dcd629ae6..72f0c43e7 100644 --- a/docs/changes/newsfragments/214.enh +++ b/docs/changes/newsfragments/214.enh @@ -1 +1 @@ -Add missing ``abstractmethod`` decorators for ``get_valid_inputs`` methods of :class:`junifer.markers.BaseMarker` and :class:`junifer.preprocess.BasePreprocessor` by `Synchon Mandal`_ \ No newline at end of file +Add missing ``abstractmethod`` decorators for ``get_valid_inputs`` methods of :class:`.BaseMarker` and :class:`.BasePreprocessor` by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/215.bugfix b/docs/changes/newsfragments/215.bugfix index 93d56dcf2..2e3885b3f 100644 --- a/docs/changes/newsfragments/215.bugfix +++ b/docs/changes/newsfragments/215.bugfix @@ -1 +1 @@ -Fix the output of :class:`junifer.markers.RSSETSMarker` to be 2D by `Synchon Mandal`_ \ No newline at end of file +Fix the output of :class:`.RSSETSMarker` to be 2D by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/216.change b/docs/changes/newsfragments/216.change index 01d731587..bbd1008f2 100644 --- a/docs/changes/newsfragments/216.change +++ b/docs/changes/newsfragments/216.change @@ -1 +1 @@ -``AmplitudeLowFrequencyFluctuationParcels`` and ``AmplitudeLowFrequencyFluctuationSpheres`` are renamed to :class:`junifer.markers.ALFFParcels` and :class:`junifer.markers.ALFFSpheres` by `Synchon Mandal`_ \ No newline at end of file +Rename ``AmplitudeLowFrequencyFluctuationParcels`` and ``AmplitudeLowFrequencyFluctuationSpheres`` to :class:`.ALFFParcels` and :class:`.ALFFSpheres` by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/218.doc b/docs/changes/newsfragments/218.doc new file mode 100644 index 000000000..62f6da514 --- /dev/null +++ b/docs/changes/newsfragments/218.doc @@ -0,0 +1 @@ +Shorten Sphinx references across code and docs, and add ``black`` shield in README by `Synchon Mandal`_ \ No newline at end of file diff --git a/docs/changes/newsfragments/64.feature b/docs/changes/newsfragments/64.feature index cde4bc078..69976419e 100644 --- a/docs/changes/newsfragments/64.feature +++ b/docs/changes/newsfragments/64.feature @@ -1 +1 @@ -Add :class:`junifer.markers.EdgeCentricFCParcels` and :class:`junifer.markers.EdgeCentricFCSpheres` by `Leonard Sasse`_ \ No newline at end of file +Add :class:`.EdgeCentricFCParcels` and :class:`.EdgeCentricFCSpheres` by `Leonard Sasse`_ \ No newline at end of file diff --git a/docs/extending/coordinates.rst b/docs/extending/coordinates.rst index 3ce75ba68..78206b549 100644 --- a/docs/extending/coordinates.rst +++ b/docs/extending/coordinates.rst @@ -6,11 +6,9 @@ Adding Coordinates ================== Instead of using whole-brain parcellations to aggregate voxel-wise signals from -MR images (as for example in the -:class:`junifer.markers.parcel_aggregation.ParcelAggregation` marker), Junifer +MR images (as for example in the :class:`.ParcelAggregation` marker), Junifer allows you to specify a set of coordinates around which to draw spheres to -aggregate (for example using the -:class:`junifer.markers.sphere_aggregation.SphereAggregation` marker) the MR +aggregate (for example using the :class:`.SphereAggregation` marker) the MR signals from individual voxels. Now, before you start specifying your own sets of coordinates, check the coordinates that Junifer already has :ref:`built in `. If you simply want to use a well known set of @@ -19,9 +17,8 @@ provides them already. If you checked the in-built coordinates, and they are not there already (for example if you came up with your own set of coordinates), then Junifer provides -an easy way for you to register them using the -:func:`junifer.data.coordinates.register_coordinates` function, so you can use -your own set of coordinates within a Junifer pipeline. +an easy way for you to register them using the :func:`.register_coordinates` +function, so you can use your own set of coordinates within a Junifer pipeline. From the API reference, we can see that it has 3 positional arguments (``name``, ``coordinates``, and ``voi_names``) as well as one @@ -30,10 +27,9 @@ optional keyword argument (``overwrite``). The ``name`` argument takes a string indicating the name you want to give to this set of coordinates. This ``name`` can be used to obtain and operate on a set of coordinates in Junifer. For example, you can obtain your coordinates -after registration by providing ``name`` to -:func:`junifer.data.coordinates.load_coordinates`. We could simply call it -``"my_set_of_coordinates"``, but likely you want a more descriptive and more -informative name most of the time. +after registration by providing ``name`` to :func:`.load_coordinates`. We could +simply call it ``"my_set_of_coordinates"``, but likely you want a more +descriptive and more informative name most of the time. The ``coordinates`` argument takes the actual coordinates as a 2-dimensional :class:`numpy.ndarray`. It contains one row for every location, and three @@ -116,8 +112,7 @@ you can use the ``with`` keyword provided by Junifer: Afterwards continue configuring the rest of your pipeline in this YAML file, and you will be able to use this set of coordinates using the name you gave it during registration (in our example "DMNCustom"). We can add a -:class:`junifer.markers.sphere_aggregation.SphereAggregation` to demonstrate -how this can be done: +:class:`.SphereAggregation` to demonstrate how this can be done: .. code-block:: yaml diff --git a/docs/extending/datagrabber.rst b/docs/extending/datagrabber.rst index 6231d4e07..e7e8b714c 100644 --- a/docs/extending/datagrabber.rst +++ b/docs/extending/datagrabber.rst @@ -13,7 +13,7 @@ the structure of a dataset and provide two specific functionalities: 2) Provide the list of *elements* available in the dataset. In this section, we will see how to create a datagrabber for a dataset. Basic -aspects of datagrabbers are covered in the +aspects of datagrabbers are covered in the :ref:`Understanding Data Grabbers ` section. .. _extending_datagrabbers_think: @@ -29,7 +29,7 @@ only one of each *data type* (see :ref:`data_types`). For example, if we have a dataset from an fMRI study in which: -a) both T1w and fMRI was acquired +a) both T1w and fMRI was acquired b) 20 subjects went through an experiment twice c) the experiment included resting-stage fMRI and a task named *stroop* @@ -64,7 +64,7 @@ Junifer provides an abstract class to deal with datasets that can be thought in terms of *patterns*. A *pattern* is a string that contains placeholders that are replaced by the actual values of the element. In our BIDS example, the path to the T1w image of subject `sub-01` and session `ses-01`, relative to the -dataset location, is ``sub-01/ses-01/anat/sub-01_ses-01_T1w.nii.gz``. By +dataset location, is ``sub-01/ses-01/anat/sub-01_ses-01_T1w.nii.gz``. By replacing ``sub-01`` with ``sub-02``, we can obtain the T1w image of the first session of the second subject. Indeed, the path to the T1w images can be expressed as a pattern: @@ -105,7 +105,7 @@ in it. Before creating the datagrabber, we need to define 3 variables: -* ``types``: A list with the available :ref:`data_types` in our dataset +* ``types``: A list with the available :ref:`data_types` in our dataset * ``patterns``: A dictionary that specifies the pattern for each data type. * ``replacements``: A list indicating which of the elements in the patterns should be replaced by the values of the element. @@ -125,7 +125,7 @@ An additional fourth variable is the ``datadir``, which should be the path to where the dataset is located. For example, if the dataset is located in ``/data/project/test/data``, then ``datadir`` should be ``/data/project/test/data``. Or, if we want to allow the user to specify the -location of the dataset, we can expose the variable in the constructor, as in +location of the dataset, we can expose the variable in the constructor, as in this example With this defined, we can now create our datagrabber, we will name it @@ -147,7 +147,7 @@ With this defined, we can now create our datagrabber, we will name it replacements = ["subject", "session"] super().__init__( datadir=datadir, - types=types, + types=types, patterns=patterns, replacements=replacements, ) @@ -175,7 +175,7 @@ use the :py:func:`~junifer.api.decorators.register_datagrabber` decorator. replacements = ["subject", "session"] super().__init__( datadir=datadir, - types=types, + types=types, patterns=patterns, replacements=replacements, ) @@ -186,29 +186,28 @@ in the yaml file to ``ExampleBIDSDataGrabber``. Remember that we still need to set the ``datadir``. .. code-block:: yaml - + datagrabber: kind: ExampleBIDSDataGrabber datadir: /data/project/test/data -Optional: Using datalad +Optional: Using datalad """"""""""""""""""""""" -If you are using `datalad`_, you can use the -:py:class:`~junifer.datagrabber.PatternDataladDataGrabber` instead of the -:py:class:`~junifer.datagrabber.PatternDataGrabber`. This class will not only +If you are using `datalad`_, you can use the :class:`.PatternDataladDataGrabber` +instead of the :class:`.PatternDataGrabber`. This class will not only interpret patterns, but also use `datalad`_ to `clone` and `get` the data. The main difference between the two is that the ``datadir`` is not the actual -location of the dataset, but the location where the dataset will be cloned. It +location of the dataset, but the location where the dataset will be cloned. It can now be ``None``, which means that the data will be downloaded to a temporary directory. To set the location of the dataset, you can use the ``uri`` argument in the constructor. Additionally, a ``rootdir`` argument can be used to specify the path to the root directory of the dataset after doing ``datalad clone``. -In the example, the dataset is hosted in gin +In the example, the dataset is hosted in gin (``https://gin.g-node.org/juaml/datalad-example-bids``). When we clone this dataset, we will see the following structure: @@ -262,7 +261,7 @@ And we can create our datagrabber: datadir=None, uri=uri, rootdir=rootdir, - types=types, + types=types, patterns=patterns, replacements=replacements, ) @@ -287,7 +286,7 @@ implement the following methods: The ``__init__`` method could also be implemented, but it is not mandatory. This is required if the datagrabber requires any parameter. -We will now implement our BIDS example with this method. +We will now implement our BIDS example with this method. The first method, ``get_item``, needs to obtain a single item from the dataset. Since this dataset requires two variables, ``subject`` and ``session``, we will use them @@ -366,11 +365,12 @@ So, to summarize, our datagrabber will look like this: def get_element_keys(self): return ["subject", "session"] -Optional: Using datalad +Optional: Using datalad """"""""""""""""""""""" -If this dataset is in a datalad dataset, we can extend from :class:`junifer.datagrabber.DataladDataGrabber` instead of -:class:`junifer.datagrabber.BaseDataGrabber`. This will allow us to use the datalad API to obtain the data. +If this dataset is in a datalad dataset, we can extend from +:class:`.DataladDataGrabber` instead of :class:`.BaseDataGrabber`. This will +allow us to use the datalad API to obtain the data. Step 4: Optional: Adding *BOLD confounds* @@ -385,7 +385,7 @@ Thus, the ``BOLD_confounds`` element is a dictionary with the following keys: - ``format``: the format of the confounds file. Currently, this can be either ``fmriprep`` or ``adhoc``. The ``fmriprep`` format corresponds to the format of the confounds files generated by `fMRIPrep`_. The -``adhoc`` format corresponds to a format that is not standardized. +``adhoc`` format corresponds to a format that is not standardized. .. note:: The ``mappings`` key is only required if the ``format`` is ``adhoc``. If the ``format`` is ``fmriprep``, the @@ -393,9 +393,9 @@ The ``fmriprep`` format corresponds to the format of the confounds files generat Currently, Junifer provides only one confound remover step -(:class:`junifer.preprocess.fMRIPrepConfoundRemover`), which relies entirely on the ``fmriprep`` confound -variable names. Thus, if the confounds are not in ``fmriprep`` format, the user will need to provide the mappings -between the *ad-hoc* variable names and the ``fmriprep`` variable names. +(:class:`.fMRIPrepConfoundRemover`), which relies entirely on the ``fmriprep`` confound +variable names. Thus, if the confounds are not in ``fmriprep`` format, the user will need to provide the mappings +between the *ad-hoc* variable names and the ``fmriprep`` variable names. This is done by specifying the ``adhoc`` format and providing the mappings as a dictionary in the ``mappings`` key. In the following example, the confounds file has 3 variables that are not in the ``fmriprep`` format. Thus, we will @@ -418,7 +418,6 @@ provide the mappings for these variables to the ``fmriprep`` format. .. note:: Not all of the mappings need to be provided. For the moment, this is used only by the - :class:`junifer.preprocess.fMRIPrepConfoundRemover` step, which requires variables based on the + :class:`.fMRIPrepConfoundRemover` step, which requires variables based on the strategy selected. However, it is recommended to provide all the mappings, as this will allow the user to choose different strategies with the same dataset. - diff --git a/docs/extending/marker.rst b/docs/extending/marker.rst index a9f79c1d5..9fb4c3180 100644 --- a/docs/extending/marker.rst +++ b/docs/extending/marker.rst @@ -9,14 +9,14 @@ Computing a marker (a.k.a. *feature*) is the main goal of junifer. While we aim it might be the case that the marker you are looking for is not available. In this case, you can create your own marker by following this tutorial. -Most of the functionality of a junifer marker has been taken care by the :class:`junifer.markers.BaseMarker` class. +Most of the functionality of a junifer marker has been taken care by the :class:`.BaseMarker` class. Thus, only a few methods are required: 1. ``get_valid_inputs``: a method to obtain the list of valid inputs for the marker. This is used to check that the - inputs provided by the user are valid. This method should return a list of strings, representing + inputs provided by the user are valid. This method should return a list of strings, representing :ref:`data types ` 2. ``get_output_type``: a method to obtain the kind of output of the marker. This is used to check that the output - of the marker is compatible with the storage. This method should return a string, representing + of the marker is compatible with the storage. This method should return a string, representing :ref:`storage types ` 3. ``compute``: the method that given the data, computes the marker. 4. ``__init__``: the initialization method, where the marker is configured. @@ -57,7 +57,7 @@ Step 2: Initialize the marker In this step we need to define the parameters of the marker. That is, all the parameters that the user can provide to configure how the marker will behave. -The parameters of the marker are defined in the ``__init__`` method. The :class:`junifer.markers.BaseMarker` class +The parameters of the marker are defined in the ``__init__`` method. The :class:`.BaseMarker` class requires two optional parameters: 1. ``name``: the name of the marker. This is used to identify the marker in the configuration file. @@ -71,13 +71,13 @@ In this example, the is only paramater required for the computation is the name define the ``__init__`` method as follows: .. code-block:: python - + def __init__(self, parcellation_name, on=None, name=None): self.parcellation_name = parcellation_name super().__init__(on=on, name=name) .. caution:: Parameters of the marker must be stored as object attributes without using ``_`` as prefix. This is - because any attribute that starts with ``_`` will not be considered as a parameter and not stored as + because any attribute that starts with ``_`` will not be considered as a parameter and not stored as part of the metadata of the marker. @@ -89,7 +89,7 @@ Step 3: Compute the marker In this step, we will define the method that computes the marker. This method will be called by junifer when needed, using the data provided by the datagrabber, as configured by the user. The function ``compute`` has two arguments: -* ``input``: a dictionary with the data to be used to compute the marker. This will be the corresponding element in the +* ``input``: a dictionary with the data to be used to compute the marker. This will be the corresponding element in the :ref:`Data Object` alredy indexing. Thus, the dictionary has at least two keys: ``data`` and ``path``. The first one contains the data, while the second one contains the path to the data. The dictionary can also contain other keys, depending on the data type. @@ -176,7 +176,7 @@ Finally, we need to register the marker using the ``@register_marker`` decorator def __init__(self, parcellation_name, on=None, name=None): self.parcellation_name = parcellation_name super().__init__(on=on, name=name) - + def get_valid_inputs(self): return ['BOLD', 'VBM_WM', 'VBM_GM'] @@ -235,7 +235,7 @@ Template for a custom Marker def __init__(self, on=None, name=None): # TODO: add marker-specific parameters super().__init__(on=on, name=name) - + def get_valid_inputs(self): # TODO: Complete with the valid inputs valid = [] diff --git a/docs/extending/masks.rst b/docs/extending/masks.rst index ae486ac29..1daa9a724 100644 --- a/docs/extending/masks.rst +++ b/docs/extending/masks.rst @@ -14,16 +14,16 @@ suit your needs, and you have found that they don't, you can come back here to learn how to use your own masks. The principle is fairly simple and quite similar to :ref:`adding_parcellations` -and :ref:`adding_coordinates`. Junifer provides a -:func:`junifer.data.masks.register_mask` function that lets you register your -own custom masks. It consists of two positional arguments (``name`` and -``mask_path``) and one optional keyword argument (``overwrite``). +and :ref:`adding_coordinates`. Junifer provides a :func:`.register_mask` +function that lets you register your own custom masks. It consists of two +positional arguments (``name`` and ``mask_path``) and one optional keyword +argument (``overwrite``). The ``name`` argument is a string indicating the name of the mask. This name is used to refer to that mask in Junifer internally in order to obtain the actual mask data and perform operations on it. For example, using the name you can load a mask after registration using the -:func:`junifer.data.masks.load_mask` function. +:func:`.load_mask` function. The ``mask_path`` should contain the path to a valid NIfTI image with binary voxel values (i.e. 0 or 1). This data can then be used by Junifer to mask other diff --git a/docs/extending/parcellations.rst b/docs/extending/parcellations.rst index 682cbb39c..7059719dd 100644 --- a/docs/extending/parcellations.rst +++ b/docs/extending/parcellations.rst @@ -16,9 +16,9 @@ markers to assess and validate your own parcellation. So, how can you do this? Since both of these use-cases are quite common, and not being able to use your favourite parcellation is of course quite a buzzkill, Junifer actually provides -the easy-to-use :func:`junifer.data.parcellations.register_parcellation` -function to do just that. Let's try to understand the API reference -and then use this function to register our own parcellation. +the easy-to-use :func:`.register_parcellation` function to do just that. Let's +try to understand the API reference and then use this function to register our +own parcellation. From the API reference, we can see that it has 3 positional arguments (``name``, ``parcellation_path``, and ``parcels_labels``) as well as one @@ -101,8 +101,7 @@ file, we can save the above code in a python file, say Afterwards continue configuring the rest of the pipeline in this YAML file, and you will be able to use this parcellation using the name you gave the parcellation when registering it. For example, we can add a -:class:`junifer.markers.parcel_aggregation.ParcelAggregation` marker to -demonstrate how this can be done: +:class:`.ParcelAggregation` marker to demonstrate how this can be done: .. code-block:: yaml diff --git a/docs/faq.rst b/docs/faq.rst index a9bc63b14..604b858de 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -21,7 +21,7 @@ The following steps are specific to VSCode and you can choose to go with it: 2. We recommend using ``conda`` to create your virtual environment - .. code-block:: console + .. code-block:: bash conda env create -n -f conda-env.yml python=3.9 conda activate diff --git a/docs/installation.rst b/docs/installation.rst index 3ed3ed335..a4164cb5f 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -11,12 +11,13 @@ junifer is compatible with `Python`_ >= 3.8 and requires the following packages: * ``click>=8.1.3,<8.2`` * ``numpy>=1.22,<1.24`` -* ``datalad>=0.15.4,<0.18`` +* ``datalad>=0.15.4,<0.19`` * ``pandas>=1.4.0,<1.6`` * ``nibabel>=3.2.0,<4.1`` -* ``nilearn>=0.9.0,<1.0`` +* ``nilearn>=0.9.0,<=0.10.0`` * ``sqlalchemy>=1.4.27,<= 1.5.0`` * ``pyyaml>=5.1.2,<7.0`` +* ``h5py>=3.8.0,<3.9`` Depending on the installation method, these packages might be installed automatically. diff --git a/docs/understanding/datagrabber.rst b/docs/understanding/datagrabber.rst index 96cd338f6..8da29f6b0 100644 --- a/docs/understanding/datagrabber.rst +++ b/docs/understanding/datagrabber.rst @@ -17,7 +17,7 @@ Datagrabbers are intended to be used as context managers. When used within a con of any pre and post steps for interacting with the dataset, for example, downloading and cleaning up. As the interface is consistent, you always use the same procedure to interact with the datagrabber. -For example, a concrete implementation of :class:`junifer.datagrabber.DataladDataGrabber` can provide junifer +For example, a concrete implementation of :class:`.DataladDataGrabber` can provide junifer with data from a Datalad dataset. Of course, datagrabbers are not only meant to work with Datalad datasets but any dataset. @@ -36,19 +36,19 @@ In this section, we showcase different abstract base classes you might want to u * - Name - Description - * - :class:`junifer.datagrabber.BaseDataGrabber` + * - :class:`.BaseDataGrabber` - | The abstract base class providing you an interface to implement your own datagrabber. | You should try to avoid using this directly and instead use - | :class:`junifer.datagrabber.PatternDataGrabber` or :class:`junifer.datagrabber.DataladDataGrabber`. + | :class:`.PatternDataGrabber` or :class:`.DataladDataGrabber`. | To build your own custom *low-level* datagrabber, you need to at least implement the ``get_elements`` method, | but most of the time you should also override other existing methods like ``__enter__`` and ``__exit__``. - * - :class:`junifer.datagrabber.PatternDataGrabber` + * - :class:`.PatternDataGrabber` - | It implements functionality to help you define the pattern of the dataset you want to get. For example, | you know that T1 images are found in a directory following this pattern ``{subject}/anat/{subject}_T1w.nii.gz`` | inside of the dataset. Now you can provide this to the **PatternDataGrabber** and it will be able to get the file. - * - :class:`junifer.datagrabber.DataladDataGrabber` + * - :class:`.DataladDataGrabber` - | It implements functionality to deal with Datalad datasets. Specifically, the ``__enter__`` and ``__exit__`` methods | take care of cloning and removing the Datalad dataset. - * - :class:`junifer.datagrabber.PatternDataladDataGrabber` - - | It is a combination of :class:`junifer.datagrabber.PatternDataladDataGrabber` and - | :class:`junifer.datagrabber.DataladDataGrabber`. This is probably the class you are looking for when using Datalad. + * - :class:`.PatternDataladDataGrabber` + - | It is a combination of :class:`.PatternDataladDataGrabber` and + | :class:`.DataladDataGrabber`. This is probably the class you are looking for when using Datalad. diff --git a/docs/understanding/datareader.rst b/docs/understanding/datareader.rst index f4717ed4b..5449b095c 100644 --- a/docs/understanding/datareader.rst +++ b/docs/understanding/datareader.rst @@ -22,7 +22,7 @@ For data formats not supported by junifer yet, you can either make your own *Dat Currently supported file-formats -------------------------------- -We already provide a concrete implementation :class:`junifer.datareader.DefaultDataReader` which knows how to +We already provide a concrete implementation :class:`.DefaultDataReader` which knows how to read the following file formats: .. list-table:: diff --git a/docs/understanding/marker.rst b/docs/understanding/marker.rst index 1ccdfce12..6c97eb613 100644 --- a/docs/understanding/marker.rst +++ b/docs/understanding/marker.rst @@ -19,5 +19,5 @@ Markers are meant to be used inside the datagrabber context but you can operate as the actual data is in the memory and the Python runtime has not garbage-collected it. If you are interested in using already provided markers, please go to :doc:`../builtin`. And, if you want to implement -your own marker, you need to provide concrete implementation of :class:`junifer.markers.BaseMarker`. Specifically, you +your own marker, you need to provide concrete implementation of :class:`.BaseMarker`. Specifically, you need to override ``get_output_type``, ``store`` and ``compute`` methods. diff --git a/docs/understanding/preprocess.rst b/docs/understanding/preprocess.rst index 99f397dc0..ae2eb0e53 100644 --- a/docs/understanding/preprocess.rst +++ b/docs/understanding/preprocess.rst @@ -23,8 +23,8 @@ The *Confound Removal* step is meant to remove *confounds* from the ``BOLD`` dat extracted from the ``BOLD_confounds`` data (must be provided by the :ref:`Data Grabber `). The confounds are then regressed out from the ``BOLD`` data using :func:`nilearn.image.clean_img`. -Currently, junifer supports only one confound removal class: -:class:`junifer.preprocess.fMRIPrepConfoundRemover`. This class is meant to remove confounds as described +Currently, junifer supports only one confound removal class: +:class:`.fMRIPrepConfoundRemover`. This class is meant to remove confounds as described before, using the output of `fMRIPrep`_ as reference. Strategy @@ -54,7 +54,7 @@ The *strategy* is defined as a dictionary, with the *noise components* as keys a Example in python format: -.. code-block:: +.. code-block:: strategy = { "motion": "basic", @@ -64,8 +64,8 @@ Example in python format: or in YAML format: -.. code-block:: - +.. code-block:: + strategy: motion: basic wm_csf: full @@ -73,7 +73,7 @@ or in YAML format: The default value is to use all the *noise components* with the ``full`` *confounds*: -.. code-block:: +.. code-block:: strategy = { "motion": "full", @@ -84,7 +84,7 @@ The default value is to use all the *noise components* with the ``full`` *confou Other parameters ~~~~~~~~~~~~~~~~ -Additionaly, the :class:`junifer.preprocess.fMRIPrepConfoundRemover` supports the following parameters: +Additionaly, the :class:`.fMRIPrepConfoundRemover` supports the following parameters: .. list-table:: :widths: 10, 30, 5 @@ -113,4 +113,4 @@ Additionaly, the :class:`junifer.preprocess.fMRIPrepConfoundRemover` supports th - from nifti header * - ``mask`` - If provided, signal is only cleaned from voxels inside the mask. If not, a mask is computed using :func:`nilearn.masking.compute_brain_mask`. - - compute \ No newline at end of file + - compute diff --git a/docs/understanding/storage.rst b/docs/understanding/storage.rst index fb637c91b..6d02712b7 100644 --- a/docs/understanding/storage.rst +++ b/docs/understanding/storage.rst @@ -17,12 +17,12 @@ as the processed data is in the memory and the Python runtime has not garbage-co The :ref:`Markers ` are responsible for defining what *storage kind* (``matrix``, ``vector``, ``timeseries``) they support for which :ref:`data type ` by overriding its ``store`` method. The storage object in turn -declares and provides implementation for specific *storage kind*. For example, :class:`junifer.storage.SQLiteFeatureStorage` +declares and provides implementation for specific *storage kind*. For example, :class:`.SQLiteFeatureStorage` supports saving ``matrix``, ``vector`` and ``timeseries`` via ``store_matrix``, ``store_vector`` and ``store_timeseries`` methods respectively. For storage interfaces not supported by junifer yet, you can either make your own ``Storage`` by providing a concrete -implementation of :class:`junifer.storage.BaseFeatureStorage` or open an issue on `junifer Github`_ and we can help you out. +implementation of :class:`.BaseFeatureStorage` or open an issue on `junifer Github`_ and we can help you out. .. _storage_types: @@ -41,15 +41,15 @@ Currently supported storage types * - ``matrix`` - A 2D matrix with row and column names - ``col_names``, ``row_names``, ``matrix_kind``, ``diagonal`` - - :meth:`junifer.storage.BaseFeatureStorage.store_matrix` + - :meth:`.BaseFeatureStorage.store_matrix` * - ``vector`` - A vector of values with column names - ``columns``, ``row_names`` - - :meth:`junifer.storage.BaseFeatureStorage.store_vector` + - :meth:`.BaseFeatureStorage.store_vector` * - ``timeseries`` - A 2D matrix of values with column names - ``columns``, ``row_names`` - - :meth:`junifer.storage.BaseFeatureStorage.store_timeseries` + - :meth:`.BaseFeatureStorage.store_timeseries` .. _storage_interfaces: @@ -64,11 +64,11 @@ Currently supported storage interfaces - File extension - File type - Storage kinds - * - :class:`junifer.storage.SQLiteFeatureStorage` + * - :class:`.SQLiteFeatureStorage` - ``.sqlite`` - SQLite - ``matrix``, ``vector``, ``timeseries`` - * - :class:`junifer.storage.HDF5FeatureStorage` + * - :class:`.HDF5FeatureStorage` - ``.hdf5`` - HDF5 - ``matrix``, ``vector``, ``timeseries`` diff --git a/docs/using/codeless.rst b/docs/using/codeless.rst index 945e08397..15fcc73cd 100644 --- a/docs/using/codeless.rst +++ b/docs/using/codeless.rst @@ -11,7 +11,7 @@ achieved by using a configuration file that is written in YAML_. In this file, w As a reminder, this is how the pipeline looks like: -.. mermaid:: +.. mermaid:: flowchart LR dg[Data Grabber] @@ -70,7 +70,7 @@ Data Grabber The ``datagrabber`` section must be configured using the ``kind`` key to specify the datagrabber to use. Additional keys correspond to the parameters of the datagrabber. -For example, to use the :class:`junifer.datagrabber.DataladAOMICPIOP1` datagrabber, we just need to +For example, to use the :class:`.DataladAOMICPIOP1` datagrabber, we just need to specify its name as the ``kind`` key. .. code-block:: yaml @@ -99,7 +99,7 @@ Data Reader ^^^^^^^^^^^ As mentioned before, this section is entirely optional, as junifer only provides one data reader -(:class:`junifer.datareader.DefaultDataReader`), which is the default in case the section is not specified. +(:class:`.DefaultDataReader`), which is the default in case the section is not specified. In any case, the syntax of the section is the same as for the ``datagrabber`` section, using the ``kind`` key to specify the data reader to use, and additional keys to pass parameters to the data reader: @@ -119,7 +119,7 @@ Preprocessing is also an optional step, as it might be the case that no pre-proc preprocessing is needed, the section must be configured using the ``kind`` key to specify the preprocessor to use, and additional keys to pass parameters to the preprocessor. -For example, to use the :class:`junifer.preprocess.fMRIPrepConfoundRemover` preprocessor, we just need to specify its +For example, to use the :class:`.fMRIPrepConfoundRemover` preprocessor, we just need to specify its name as the ``kind`` key, as well as its parameters. @@ -173,7 +173,7 @@ Storage Finally, we need to define how and where the results will be stored. This is done using the ``storage`` section, which must be configured using the ``kind`` key to specify the storage to use, and additional keys to pass parameters. -For example, to use the :class:`junifer.storage.SQLiteFeatureStorage` storage, we just need to specify where we want +For example, to use the :class:`.SQLiteFeatureStorage` storage, we just need to specify where we want to store the results: .. code-block:: yaml diff --git a/docs/using/masks.rst b/docs/using/masks.rst index dd09d1d42..fbaa64b6d 100644 --- a/docs/using/masks.rst +++ b/docs/using/masks.rst @@ -11,12 +11,12 @@ voxels that contain a certain ratio of gray matter to white matter / cerebrospin are not extracted from voxels that contain mostly white matter or cerebrospinal fluid, which could add noise to the BOLD signal. -Junifer provides a number of built-in masks, which can be listed using the :func:`junifer.data.masks.list_masks`. Some -masks are images, while other masks can be computed using :ref:`nilearn` functions. +Junifer provides a number of built-in masks, which can be listed using the :func:`.list_masks`. Some +masks are images, while other masks can be computed using :ref:`nilearn` functions. For markers and steps that accept ``masks`` as an argument, the mask can be specified as a string, which will be the -name of a built-in mask, or as a dictionary in which the **only** key is the built-in mask name and the value is a -dictionary of keyword arguments to pass to the mask function. +name of a built-in mask, or as a dictionary in which the **only** key is the built-in mask name and the value is a +dictionary of keyword arguments to pass to the mask function. For example, the following is a valid mask specification that specified the ``GM_prob0.2`` mask. @@ -29,7 +29,7 @@ with a threshold of 0.5. .. code-block:: yaml - masks: + masks: compute_brain_mask: threshold: 0.5 @@ -39,7 +39,7 @@ is a valid mask specification that specifies the intersection of the ``GM_prob0. .. code-block:: yaml - masks: + masks: - GM_prob0.2 - compute_brain_mask: threshold: 0.5 @@ -50,7 +50,7 @@ following example combines the same masks as the previous one, but computing the .. code-block:: yaml - masks: + masks: - GM_prob0.2 - compute_brain_mask: threshold: 0.5 @@ -60,9 +60,9 @@ Alternatively, we can also compute the union, even if the voxels do not form a c .. code-block:: yaml - masks: + masks: - GM_prob0.2 - compute_brain_mask: threshold: 0.5 - threshold: 0 # union - - connected: False # keep disconnected components \ No newline at end of file + - connected: False # keep disconnected components diff --git a/docs/using/running.rst b/docs/using/running.rst index 9bd1cfad9..87257c741 100644 --- a/docs/using/running.rst +++ b/docs/using/running.rst @@ -14,7 +14,7 @@ individual results into a single file. Assuming that we have a configuration file named ``config.yaml``, the following commands will extract the features: -.. code-block:: console +.. code-block:: bash junifer run config.yaml @@ -22,20 +22,20 @@ The ``run`` command accepts the following additional arguments: * ``--help``: Show a help message. * ``--verbose`` Set the verbosity level. Options are ``warning``, ``info``, ``debug``. -* ``--element``: The *element* to run. If not specified, all elements will be run. This parameter can be specified +* ``--element``: The *element* to run. If not specified, all elements will be run. This parameter can be specified multiple times to run multiple elements. If the *element* requires several parameters, they can be specified by separating them with ``,``. Example on running two elements: -.. code-block:: console +.. code-block:: bash junifer run config.yaml --element sub-01 --element sub-02 Example on elements with multiple parameters and verbose output: -.. code-block:: console +.. code-block:: bash junifer run --verbose info config.yaml --element sub-01,ses-01 @@ -50,7 +50,7 @@ individual results into a single file. Assuming that we have a configuration file named ``config.yaml``, the following commands will collect the results: -.. code-block:: console +.. code-block:: bash junifer collect config.yaml diff --git a/docs/whats_new.rst b/docs/whats_new.rst index 4434cfc72..0d1e8c262 100644 --- a/docs/whats_new.rst +++ b/docs/whats_new.rst @@ -20,13 +20,12 @@ API Changes Bugfixes ^^^^^^^^ -- Fix a bug in which a :class:`junifer.datagrabber.PatternDataGrabber` would - now work with relative ``datadir`` paths (reported by `Leonard Sasse`_, - fixed by `Fede Raimondo`_) (:gh:`96`, :gh:`98`) +- Fix a bug in which a :class:`.PatternDataGrabber` would now work with + relative ``datadir`` paths (reported by `Leonard Sasse`_, fixed by + `Fede Raimondo`_) (:gh:`96`, :gh:`98`) -- Fix a bug in which :class:`junifer.datagrabber.DataladAOMICPIOP2` datagrabber - did not use user input to constrain elements based on tasks by - `Leonard Sasse`_ (:gh:`105`) +- Fix a bug in which :class:`.DataladAOMICPIOP2` datagrabber did not use user + input to constrain elements based on tasks by `Leonard Sasse`_ (:gh:`105`) - Fix a bug in which a datalad dataset could remove a user-cloned dataset by `Fede Raimondo`_ (:gh:`53`) @@ -53,9 +52,9 @@ Improved Documentation Enhancements ^^^^^^^^^^^^ -- Add comments to :class:`junifer.datagrabber.DataladDataGrabber` datagrabber - and change to use ``datalad-clone`` instead of ``datalad-install`` by - `Benjamin Poldrack`_ (:gh:`55`) +- Add comments to :class:`.DataladDataGrabber` datagrabber and change to use + ``datalad-clone`` instead of ``datalad-install`` by `Benjamin Poldrack`_ + (:gh:`55`) - Upgrade storage interface for storage-like objects by `Synchon Mandal`_ (:gh:`84`) @@ -65,65 +64,64 @@ Enhancements - Refactor markers ``on`` attribute and ``get_valid_inputs`` to verify that the marker can be computed on the input data types by `Fede Raimondo`_ -- Add test for :class:`junifer.datagrabber.DataladHCP1200` datagrabber by - `Synchon Mandal`_ (:gh:`93`) +- Add test for :class:`.DataladHCP1200` datagrabber by `Synchon Mandal`_ + (:gh:`93`) + +- Refactor :class:`.DataladAOMICID1000` slightly by `Leonard Sasse`_ (:gh:`94`) - Rename "atlas" to "parcellation" by `Fede Raimondo`_ (:gh:`116`) -- Refactor the :class:`junifer.datagrabber.BaseDataGrabber` class to allow for - easier subclassing by `Fede Raimondo`_ (:gh:`123`) +- Refactor the :class:`.BaseDataGrabber` class to allow for easier subclassing + by `Fede Raimondo`_ (:gh:`123`) -- Allow custom aggregation method for :class:`junifer.markers.SphereAggregation` - by `Synchon Mandal`_ (:gh:`102`) +- Allow custom aggregation method for :class:`.SphereAggregation` by + `Synchon Mandal`_ (:gh:`102`) - Add support for "masks" by `Fede Raimondo`_ (:gh:`79`) -- Allow :class:`junifer.markers.ParcelAggregation` to apply multiple - parcellations at once by `Fede Raimondo`_ (:gh:`131`) +- Allow :class:`.ParcelAggregation` to apply multiple parcellations at once by + `Fede Raimondo`_ (:gh:`131`) -- Refactor :class:`junifer.pipeline.PipelineStepMixin` to improve its - implementation and validation for pipeline steps by `Synchon Mandal`_ - (:gh:`152`) +- Refactor :class:`.PipelineStepMixin` to improve its implementation and + validation for pipeline steps by `Synchon Mandal`_ (:gh:`152`) Features ^^^^^^^^ -- Implement :class:`junifer.testing.datagrabbers.SPMAuditoryTestingDatagrabber` - datagrabber by `Fede Raimondo`_ (:gh:`52`) +- Implement :class:`.SPMAuditoryTestingDatagrabber` datagrabber by + `Fede Raimondo`_ (:gh:`52`) - Implement matrix storage in SQliteFeatureStorage by `Fede Raimondo`_ (:gh:`42`) -- Implement :class:`junifer.markers.FunctionalConnectivityParcels` marker for - functional connectivity using a parcellation by `Amir Omidvarnia`_ and +- Implement :class:`.FunctionalConnectivityParcels` marker for functional + connectivity using a parcellation by `Amir Omidvarnia`_ and `Kaustubh R. Patil`_ (:gh:`41`) -- Implement coordinate register, list and load by `Fede Raimondo`_ (:gh:`11`) +- Implement :func:`.register_coordinates`, :func:`.list_coordinates` and + :func:`.load_coordinates` by `Fede Raimondo`_ (:gh:`11`) -- Add :class:`junifer.datagrabber.DataladAOMICID1000` datagrabber for AOMIC - ID1000 dataset including tests and creation of mock dataset for testing by +- Add :class:`.DataladAOMICID1000` datagrabber for AOMIC ID1000 dataset + including tests and creation of mock dataset for testing by `Vera Komeyer`_ and `Xuan Li`_ (:gh:`60`) - Add support to access other input in the data object in the ``compute`` method by `Fede Raimondo`_ -- Implement :class:`junifer.markers.RSSETSMarker` marker by `Leonard Sasse`_, - `Nicolas Nieto`_ and `Sami Hamdan`_ (:gh:`51`) +- Implement :class:`.RSSETSMarker` marker by `Leonard Sasse`_, `Nicolas Nieto`_ + and `Sami Hamdan`_ (:gh:`51`) -- Implement :class:`junifer.markers.SphereAggregation` marker by - `Fede Raimondo`_ +- Implement :class:`.SphereAggregation` marker by `Fede Raimondo`_ (:gh:`83`) -- Implement :class:`junifer.datagrabber.DataladAOMICPIOP1` and - :class:`junifer.datagrabber.DataladAOMICPIOP2` datagrabbers for AOMIC PIOP1 - and PIOP2 datasets respectively and refactor - :class:`junifer.datagrabber.DataladAOMICID1000` slightly by `Leonard Sasse`_ - (:gh:`94`) +- Implement :class:`.DataladAOMICPIOP1` and :class:`.DataladAOMICPIOP2` + datagrabbers for AOMIC PIOP1 and PIOP2 datasets respectively by + `Leonard Sasse`_ (:gh:`94`) -- Implement :class:`junifer.configs.juseless.datagrabbers.JuselessDataladCamCANVBM` - datagrabber by `Leonard Sasse`_ (:gh:`99`) +- Implement :class:`.JuselessDataladCamCANVBM` datagrabber by `Leonard Sasse`_ + (:gh:`99`) -- Implement :class:`junifer.configs.juseless.datagrabbers.JuselessDataladIXIVBM` - CAT output datagrabber for juseless by `Leonard Sasse`_ (:gh:`48`) +- Implement :class:`.JuselessDataladIXIVBM` CAT output datagrabber for juseless + by `Leonard Sasse`_ (:gh:`48`) - Add ``junifer wtf`` to report environment details by `Synchon Mandal`_ (:gh:`33`) @@ -131,27 +129,27 @@ Features - Add ``junifer selftest`` to report environment details by `Synchon Mandal`_ (:gh:`9`) -- Implement :class:`junifer.configs.juseless.datagrabbers.JuselessDataladAOMICID1000VBM` - datagrabber for accessing AOMIC ID1000 VBM from juseless by `Felix Hoffstaedter`_ - and `Synchon Mandal`_ (:gh:`57`) +- Implement :class:`.JuselessDataladAOMICID1000VBM` datagrabber for accessing + AOMIC ID1000 VBM from juseless by `Felix Hoffstaedter`_ and `Synchon Mandal`_ + (:gh:`57`) -- Add :class:`junifer.preprocess.fMRIPrepConfoundRemover` by `Fede Raimondo`_ - and `Leonard Sasse`_ (:gh:`111`) +- Add :class:`.fMRIPrepConfoundRemover` by `Fede Raimondo`_ and `Leonard Sasse`_ + (:gh:`111`) -- Implement :class:`junifer.markers.CrossParcellationFC` marker by - `Leonard Sasse`_ and `Kaustubh R. Patil`_ (:gh:`85`) +- Implement :class:`.CrossParcellationFC` marker by `Leonard Sasse`_ and + `Kaustubh R. Patil`_ (:gh:`85`) -- Add :class:`junifer.configs.juseless.datagrabbers.JuselessUCLA` datagrabber - for the UCLA dataset available on juseless by `Leonard Sasse`_ (:gh:`118`) +- Add :class:`.JuselessUCLA` datagrabber for the UCLA dataset available on + juseless by `Leonard Sasse`_ (:gh:`118`) - Introduce a singleton decorator for marker computations by `Synchon Mandal`_ (:gh:`151`) -- Implement :class:`junifer.markers.ReHoParcels` and - :class:`junifer.markers.ReHoSpheres` markers by `Synchon Mandal`_ (:gh:`36`) +- Implement :class:`.ReHoParcels` and :class:`.ReHoSpheres` markers by + `Synchon Mandal`_ (:gh:`36`) -- Implement :class:`junifer.markers.ALFFParcels` and - :class:`junifer.markers.ALFFSpheres` markers by `Fede Raimondo`_ (:gh:`35`) +- Implement :class:`.ALFFParcels` and :class:`.ALFFSpheres` markers by + `Fede Raimondo`_ (:gh:`35`) Misc ^^^^ diff --git a/junifer/api/functions.py b/junifer/api/functions.py index 725a2636f..6c1a2a7cc 100644 --- a/junifer/api/functions.py +++ b/junifer/api/functions.py @@ -515,10 +515,11 @@ def _queue_condor( collect_pre_fname = jobdir / "collect_pre.sh" dag_file.write( f"SCRIPT PRE collect {collect_pre_fname.as_posix()} " - "$DAG_STATUS\n") + "$DAG_STATUS\n" + ) with open(collect_pre_fname, "w") as pre_file: pre_file.write("#!/bin/bash\n\n") - pre_file.write("if [ \"${1}\" == \"4\" ]; then\n") + pre_file.write('if [ "${1}" == "4" ]; then\n') pre_file.write(" exit 1\n") pre_file.write("fi\n") diff --git a/junifer/data/parcellations.py b/junifer/data/parcellations.py index 490cf6408..88973dc55 100644 --- a/junifer/data/parcellations.py +++ b/junifer/data/parcellations.py @@ -167,7 +167,7 @@ def load_parcellation( ---------- name : str The name of the parcellation. Check valid options by calling - :func:`junifer.data.parcellations.list_parcellations`. + :func:`.list_parcellations`. parcellations_dir : str or pathlib.Path, optional Path where the parcellations files are stored. The default location is "$HOME/junifer/data/parcellations" (default None). diff --git a/junifer/datagrabber/hcp.py b/junifer/datagrabber/hcp.py index d36e74b61..d1048c034 100644 --- a/junifer/datagrabber/hcp.py +++ b/junifer/datagrabber/hcp.py @@ -26,12 +26,9 @@ class HCP1200(PatternDataGrabber): phase_encodings : {"LR", "RL"} or list of the options, optional HCP phase encoding directions. If None, both will be used (default None). - ica_fix : bool, optional - Whether to retrieve data that was processed with ICA+FIX. - Only 'REST1' and 'REST2' tasks are available with ICA+FIX (default - False). **kwargs Keyword arguments passed to superclass. + """ def __init__( @@ -39,7 +36,6 @@ class HCP1200(PatternDataGrabber): datadir: Union[str, Path], tasks: Union[str, List[str], None] = None, phase_encodings: Union[str, List[str], None] = None, - ica_fix: bool = False, **kwargs, ) -> None: # All tasks @@ -86,12 +82,6 @@ class HCP1200(PatternDataGrabber): f"{all_phase_encodings}." ) - if ica_fix: - if not all([task in ["REST1", "REST2"] for task in self.tasks]): - raise_error( - "ICA+FIX is only available for 'REST1' and 'REST2' tasks." - ) - suffix = "_hp2000_clean" if ica_fix else "" # The types of data types = ["BOLD"] # The patterns @@ -99,8 +89,7 @@ class HCP1200(PatternDataGrabber): "BOLD": ( "{subject}/MNINonLinear/Results/" "{task}_{phase_encoding}/" - "{task}_{phase_encoding}" - f"{suffix}.nii.gz" + "{task}_{phase_encoding}_hp2000_clean.nii.gz" ) } # The replacements @@ -184,10 +173,6 @@ class DataladHCP1200(DataladDataGrabber, HCP1200): phase_encodings : {"LR", "RL"} or list of the options, optional HCP phase encoding directions. If None, both will be used (default None). - ica_fix : bool, optional - Whether to retrieve data that was processed with ICA+FIX. - Only 'REST1' and 'REST2' tasks are available with ICA+FIX (default - False). """ def __init__( @@ -195,7 +180,6 @@ class DataladHCP1200(DataladDataGrabber, HCP1200): datadir: Union[str, Path, None] = None, tasks: Union[str, List[str], None] = None, phase_encodings: Union[str, List[str], None] = None, - ica_fix: bool = False, ) -> None: uri = ( "https://github.com/datalad-datasets/" @@ -208,7 +192,6 @@ class DataladHCP1200(DataladDataGrabber, HCP1200): phase_encodings=phase_encodings, uri=uri, rootdir=rootdir, - ica_fix=ica_fix, ) @property diff --git a/junifer/datagrabber/tests/test_hcp.py b/junifer/datagrabber/tests/test_hcp.py index c5ca8ec5b..375f4409d 100644 --- a/junifer/datagrabber/tests/test_hcp.py +++ b/junifer/datagrabber/tests/test_hcp.py @@ -29,38 +29,33 @@ def hcpdg() -> Iterable[DataladHCP1200]: @pytest.mark.parametrize( - "tasks, phase_encodings, ica_fix, expected_path_name", + "tasks, phase_encodings, expected_path_name", [ - (None, None, False, "rfMRI_REST1_LR.nii.gz"), - ("REST1", "LR", False, "rfMRI_REST1_LR.nii.gz"), - ("REST1", "RL", False, "rfMRI_REST1_RL.nii.gz"), - ("REST2", "LR", False, "rfMRI_REST2_LR.nii.gz"), - ("REST2", "RL", False, "rfMRI_REST2_RL.nii.gz"), - ("SOCIAL", "LR", False, "tfMRI_SOCIAL_LR.nii.gz"), - ("SOCIAL", "RL", False, "tfMRI_SOCIAL_RL.nii.gz"), - ("WM", "LR", False, "tfMRI_WM_LR.nii.gz"), - ("WM", "RL", False, "tfMRI_WM_RL.nii.gz"), - ("RELATIONAL", "LR", False, "tfMRI_RELATIONAL_LR.nii.gz"), - ("RELATIONAL", "RL", False, "tfMRI_RELATIONAL_RL.nii.gz"), - ("EMOTION", "LR", False, "tfMRI_EMOTION_LR.nii.gz"), - ("EMOTION", "RL", False, "tfMRI_EMOTION_RL.nii.gz"), - ("LANGUAGE", "LR", False, "tfMRI_LANGUAGE_LR.nii.gz"), - ("LANGUAGE", "RL", False, "tfMRI_LANGUAGE_RL.nii.gz"), - ("GAMBLING", "LR", False, "tfMRI_GAMBLING_LR.nii.gz"), - ("GAMBLING", "RL", False, "tfMRI_GAMBLING_RL.nii.gz"), - ("MOTOR", "LR", False, "tfMRI_MOTOR_LR.nii.gz"), - ("MOTOR", "RL", False, "tfMRI_MOTOR_RL.nii.gz"), - ("REST1", "LR", True, "rfMRI_REST1_LR_hp2000_clean.nii.gz"), - ("REST1", "RL", True, "rfMRI_REST1_RL_hp2000_clean.nii.gz"), - ("REST2", "LR", True, "rfMRI_REST2_LR_hp2000_clean.nii.gz"), - ("REST2", "RL", True, "rfMRI_REST2_RL_hp2000_clean.nii.gz"), + (None, None, "rfMRI_REST1_LR_hp2000_clean.nii.gz"), + ("REST1", "LR", "rfMRI_REST1_LR_hp2000_clean.nii.gz"), + ("REST1", "RL", "rfMRI_REST1_RL_hp2000_clean.nii.gz"), + ("REST2", "LR", "rfMRI_REST2_LR_hp2000_clean.nii.gz"), + ("REST2", "RL", "rfMRI_REST2_RL_hp2000_clean.nii.gz"), + ("SOCIAL", "LR", "tfMRI_SOCIAL_LR_hp2000_clean.nii.gz"), + ("SOCIAL", "RL", "tfMRI_SOCIAL_RL_hp2000_clean.nii.gz"), + ("WM", "LR", "tfMRI_WM_LR_hp2000_clean.nii.gz"), + ("WM", "RL", "tfMRI_WM_RL_hp2000_clean.nii.gz"), + ("RELATIONAL", "LR", "tfMRI_RELATIONAL_LR_hp2000_clean.nii.gz"), + ("RELATIONAL", "RL", "tfMRI_RELATIONAL_RL_hp2000_clean.nii.gz"), + ("EMOTION", "LR", "tfMRI_EMOTION_LR_hp2000_clean.nii.gz"), + ("EMOTION", "RL", "tfMRI_EMOTION_RL_hp2000_clean.nii.gz"), + ("LANGUAGE", "LR", "tfMRI_LANGUAGE_LR_hp2000_clean.nii.gz"), + ("LANGUAGE", "RL", "tfMRI_LANGUAGE_RL_hp2000_clean.nii.gz"), + ("GAMBLING", "LR", "tfMRI_GAMBLING_LR_hp2000_clean.nii.gz"), + ("GAMBLING", "RL", "tfMRI_GAMBLING_RL_hp2000_clean.nii.gz"), + ("MOTOR", "LR", "tfMRI_MOTOR_LR_hp2000_clean.nii.gz"), + ("MOTOR", "RL", "tfMRI_MOTOR_RL_hp2000_clean.nii.gz"), ], ) def test_hcp1200_datagrabber( hcpdg: DataladHCP1200, tasks: Optional[str], phase_encodings: Optional[str], - ica_fix: bool, expected_path_name: str, ) -> None: """Test HCP1200 datagrabber. @@ -74,8 +69,6 @@ def test_hcp1200_datagrabber( The parametrized tasks. phase_encodings : str The parametrized phase encodings. - ica_fix : bool - The parametrized ICA-FIX flag. expected_path_name : str The parametrized expected path name. @@ -85,7 +78,6 @@ def test_hcp1200_datagrabber( datadir=hcpdg.datadir, tasks=tasks, phase_encodings=phase_encodings, - ica_fix=ica_fix, ) # Get all elements all_elements = dg.get_elements() @@ -350,38 +342,3 @@ def test_hcp1200_datagrabber_elements( assert element[2] in ["LR", "RL"] assert set(found_subjects) == set(expected_subjects) - - -@pytest.mark.parametrize( - "tasks, ica_fix", - [ - ("SOCIAL", True), - ("WM", True), - ("RELATIONAL", True), - ("EMOTION", True), - ("LANGUAGE", True), - ("GAMBLING", True), - ("MOTOR", True), - ], -) -def test_hcp1200_datagrabber_incorrect_access_icafix( - tasks: Optional[str], - ica_fix: bool -) -> None: - """Test HCP1200 datagrabber incorrect access for icafix. - - Parameters - ---------- - tasks : str - The parametrized tasks. - ica_fix : bool - The parametrized ICA-FIX flag. - - """ - configure_logging(level="DEBUG") - with pytest.raises(ValueError, match="is only available for"): - _ = HCP1200( - datadir=".", - tasks=tasks, - ica_fix=ica_fix, - ) diff --git a/junifer/markers/ets_rss.py b/junifer/markers/ets_rss.py index bb4eeef5d..971d017a3 100644 --- a/junifer/markers/ets_rss.py +++ b/junifer/markers/ets_rss.py @@ -25,13 +25,13 @@ class RSSETSMarker(BaseMarker): ---------- parcellation : str or list of str The name(s) of the parcellation(s). Check valid options by calling - :func:`junifer.data.parcellations.list_parcellations`. + :func:`.list_parcellations`. agg_method : str, optional The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default "mean"). + :func:`.get_aggfunc_by_name` (default "mean"). agg_method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default None). + :func:`.get_aggfunc_by_name` (default None). masks : str, dict or list of dict or str, optional The specification of the masks to apply to regions before extracting signals. Check :ref:`Using Masks ` for more details. diff --git a/junifer/markers/falff/falff_estimator.py b/junifer/markers/falff/falff_estimator.py index e1070f1af..ef651d485 100644 --- a/junifer/markers/falff/falff_estimator.py +++ b/junifer/markers/falff/falff_estimator.py @@ -33,8 +33,8 @@ class ALFFEstimator: by caching the voxel-wise ALFF map for a given set of file path and computation parameters. - .. warning:: This class can only be used via - :class:`junifer.markers.falff.ALFFBase` as it serves a specific purpose. + .. warning:: This class can only be used via :class:`.ALFFBase` as it + serves a specific purpose. Parameters ---------- diff --git a/junifer/markers/falff/falff_parcels.py b/junifer/markers/falff/falff_parcels.py index 2e02e368d..1c8a73a7a 100644 --- a/junifer/markers/falff/falff_parcels.py +++ b/junifer/markers/falff/falff_parcels.py @@ -20,7 +20,7 @@ class ALFFParcels(ALFFBase): ---------- parcellation : str or list of str The name(s) of the parcellation(s). Check valid options by calling - :func:`junifer.data.parcellations.list_parcellations`. + :func:`.list_parcellations`. fractional : bool Whether to compute fractional ALFF. highpass : positive float, optional @@ -40,10 +40,10 @@ class ALFFParcels(ALFFBase): If None, will not apply any mask (default None). method : str, optional The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default "mean"). + :func:`.get_aggfunc_by_name` (default "mean"). method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name`. + :func:`.get_aggfunc_by_name`. name : str, optional The name of the marker. If None, will use the class name (default None). diff --git a/junifer/markers/falff/falff_spheres.py b/junifer/markers/falff/falff_spheres.py index 2d38a195d..51132ef03 100644 --- a/junifer/markers/falff/falff_spheres.py +++ b/junifer/markers/falff/falff_spheres.py @@ -20,7 +20,7 @@ class ALFFSpheres(ALFFBase): ---------- coords : str The name of the coordinates list to use. See - :func:`junifer.data.coordinates.list_coordinates` for options. + :func:`.list_coordinates` for options. radius : float, optional The radius of the sphere in mm. If None, the signal will be extracted from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker` @@ -47,10 +47,10 @@ class ALFFSpheres(ALFFBase): If None, will not apply any mask (default None). method : str, optional The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default "mean"). + :func:`.get_aggfunc_by_name` (default "mean"). method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name`. + :func:`.get_aggfunc_by_name`. name : str, optional The name of the marker. If None, will use the class name (default None). diff --git a/junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py b/junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py index 38f1d8425..5873a2b0f 100644 --- a/junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py +++ b/junifer/markers/functional_connectivity/edge_functional_connectivity_parcels.py @@ -20,14 +20,14 @@ class EdgeCentricFCParcels(FunctionalConnectivityBase): ---------- parcellation : str or list of str The name(s) of the parcellation(s). Check valid options by calling - :func:`junifer.data.parcellations.list_parcellations`. + :func:`.list_parcellations`. agg_method : str, optional The method to perform aggregation of BOLD time series. - Check valid options in :func:`junifer.stats.get_aggfunc_by_name` + Check valid options in :func:`.get_aggfunc_by_name` (default "mean"). agg_method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default None). + :func:`.get_aggfunc_by_name` (default None). cor_method : str, optional The method to perform correlation. Check valid options in :class:`nilearn.connectome.ConnectivityMeasure` diff --git a/junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py b/junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py index 22aae75b2..60554752d 100644 --- a/junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py +++ b/junifer/markers/functional_connectivity/edge_functional_connectivity_spheres.py @@ -20,7 +20,7 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase): ---------- coords : str The name of the coordinates list to use. See - :func:`junifer.data.coordinates.list_coordinates` for options. + :func:`.list_coordinates` for options. radius : float, optional The radius of the sphere in mm. If None, the signal will be extracted from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker` @@ -30,7 +30,7 @@ class EdgeCentricFCSpheres(FunctionalConnectivityBase): the spheres overlap (default is False). agg_method : str, optional The aggregation method to use. - See :func:`junifer.stats.get_aggfunc_by_name` for more information + See :func:`.get_aggfunc_by_name` for more information (default None). agg_method_params : dict, optional The parameters to pass to the aggregation method (default None). diff --git a/junifer/markers/functional_connectivity/functional_connectivity_base.py b/junifer/markers/functional_connectivity/functional_connectivity_base.py index 72f7ad135..d893baa3c 100644 --- a/junifer/markers/functional_connectivity/functional_connectivity_base.py +++ b/junifer/markers/functional_connectivity/functional_connectivity_base.py @@ -21,10 +21,10 @@ class FunctionalConnectivityBase(BaseMarker): ---------- agg_method : str, optional The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default "mean"). + :func:`.get_aggfunc_by_name` (default "mean"). agg_method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default None). + :func:`.get_aggfunc_by_name` (default None). cor_method : str, optional The method to perform correlation using. Check valid options in :class:`nilearn.connectome.ConnectivityMeasure` diff --git a/junifer/markers/functional_connectivity/functional_connectivity_parcels.py b/junifer/markers/functional_connectivity/functional_connectivity_parcels.py index b77927312..935af35da 100644 --- a/junifer/markers/functional_connectivity/functional_connectivity_parcels.py +++ b/junifer/markers/functional_connectivity/functional_connectivity_parcels.py @@ -20,13 +20,13 @@ class FunctionalConnectivityParcels(FunctionalConnectivityBase): ---------- parcellation : str or list of str The name(s) of the parcellation(s). Check valid options by calling - :func:`junifer.data.parcellations.list_parcellations`. + :func:`.list_parcellations`. agg_method : str, optional The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default "mean"). + :func:`.get_aggfunc_by_name` (default "mean"). agg_method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default None). + :func:`.get_aggfunc_by_name` (default None). cor_method : str, optional The method to perform correlation using. Check valid options in :class:`nilearn.connectome.ConnectivityMeasure` diff --git a/junifer/markers/functional_connectivity/functional_connectivity_spheres.py b/junifer/markers/functional_connectivity/functional_connectivity_spheres.py index 517eb1820..8ad915926 100644 --- a/junifer/markers/functional_connectivity/functional_connectivity_spheres.py +++ b/junifer/markers/functional_connectivity/functional_connectivity_spheres.py @@ -21,7 +21,7 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase): ---------- coords : str The name of the coordinates list to use. See - :func:`junifer.data.coordinates.list_coordinates` for options. + :func:`.list_coordinates` for options. radius : float, optional The radius of the sphere in mm. If None, the signal will be extracted from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker` @@ -31,7 +31,7 @@ class FunctionalConnectivitySpheres(FunctionalConnectivityBase): the spheres overlap (default is False). agg_method : str, optional The aggregation method to use. - See :func:`junifer.stats.get_aggfunc_by_name` for more information + See :func:`.get_aggfunc_by_name` for more information (default None). agg_method_params : dict, optional The parameters to pass to the aggregation method (default None). diff --git a/junifer/markers/parcel_aggregation.py b/junifer/markers/parcel_aggregation.py index 20d0a7257..3cd3cae65 100644 --- a/junifer/markers/parcel_aggregation.py +++ b/junifer/markers/parcel_aggregation.py @@ -25,13 +25,13 @@ class ParcelAggregation(BaseMarker): ---------- parcellation : str or list of str The name(s) of the parcellation(s). Check valid options by calling - :func:`junifer.data.parcellations.list_parcellations`. + :func:`.list_parcellations`. method : str The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name`. + :func:`.get_aggfunc_by_name`. method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name`. + :func:`.get_aggfunc_by_name`. time_method : str, optional The method to use to aggregate the time series over the time points, after applying :term:`method` (only applicable to BOLD data). If None, diff --git a/junifer/markers/reho/reho_parcels.py b/junifer/markers/reho/reho_parcels.py index fdc0c5f0c..69dbb6bd0 100644 --- a/junifer/markers/reho/reho_parcels.py +++ b/junifer/markers/reho/reho_parcels.py @@ -22,7 +22,7 @@ class ReHoParcels(ReHoBase): ---------- parcellation : str The name of the parcellation. Check valid options by calling - :func:`junifer.data.parcellations.list_parcellations`. + :func:`.list_parcellations`. use_afni : bool, optional Whether to use AFNI for computing. If None, will use AFNI only if available (default None). @@ -70,10 +70,10 @@ class ReHoParcels(ReHoBase): agg_method : str, optional The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default "mean"). + :func:`.get_aggfunc_by_name` (default "mean"). agg_method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default None). + :func:`.get_aggfunc_by_name` (default None). masks : str, dict or list of dict or str, optional The specification of the masks to apply to regions before extracting signals. Check :ref:`Using Masks ` for more details. diff --git a/junifer/markers/reho/reho_spheres.py b/junifer/markers/reho/reho_spheres.py index 4db4ed928..773db71c4 100644 --- a/junifer/markers/reho/reho_spheres.py +++ b/junifer/markers/reho/reho_spheres.py @@ -22,7 +22,7 @@ class ReHoSpheres(ReHoBase): ---------- coords : str The name of the coordinates list to use. See - :func:`junifer.data.coordinates.list_coordinates` for options. + :func:`.list_coordinates` for options. radius : float, optional The radius of the sphere in millimeters. If None, the signal will be extracted from a single voxel. See @@ -78,7 +78,7 @@ class ReHoSpheres(ReHoBase): agg_method : str, optional The aggregation method to use. - See :func:`junifer.stats.get_aggfunc_by_name` for more information + See :func:`.get_aggfunc_by_name` for more information (default None). agg_method_params : dict, optional The parameters to pass to the aggregation method (default None). diff --git a/junifer/markers/sphere_aggregation.py b/junifer/markers/sphere_aggregation.py index 1a30bccdb..8aad154ec 100644 --- a/junifer/markers/sphere_aggregation.py +++ b/junifer/markers/sphere_aggregation.py @@ -22,7 +22,7 @@ class SphereAggregation(BaseMarker): ---------- coords : str The name of the coordinates list to use. See - :func:`junifer.data.coordinates.list_coordinates` for options. + :func:`.list_coordinates` for options. radius : float, optional The radius of the sphere in millimeters. If None, the signal will be extracted from a single voxel. See @@ -33,7 +33,7 @@ class SphereAggregation(BaseMarker): the spheres overlap (default is False). method : str, optional The aggregation method to use. - See :func:`junifer.stats.get_aggfunc_by_name` for more information + See :func:`.get_aggfunc_by_name` for more information (default "mean"). method_params : dict, optional The parameters to pass to the aggregation method (default None). diff --git a/junifer/markers/temporal_snr/temporal_snr_base.py b/junifer/markers/temporal_snr/temporal_snr_base.py index 7679c6c8e..3809d0fad 100644 --- a/junifer/markers/temporal_snr/temporal_snr_base.py +++ b/junifer/markers/temporal_snr/temporal_snr_base.py @@ -20,10 +20,10 @@ class TemporalSNRBase(BaseMarker): ---------- agg_method : str, optional The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default "mean"). + :func:`.get_aggfunc_by_name` (default "mean"). agg_method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default None). + :func:`.get_aggfunc_by_name` (default None). masks : str, dict or list of dict or str, optional The specification of the masks to apply to regions before extracting signals. Check :ref:`Using Masks ` for more details. diff --git a/junifer/markers/temporal_snr/temporal_snr_parcels.py b/junifer/markers/temporal_snr/temporal_snr_parcels.py index 0521527de..3c18ceccf 100644 --- a/junifer/markers/temporal_snr/temporal_snr_parcels.py +++ b/junifer/markers/temporal_snr/temporal_snr_parcels.py @@ -18,13 +18,13 @@ class TemporalSNRParcels(TemporalSNRBase): ---------- parcellation : str or list of str The name(s) of the parcellation(s). Check valid options by calling - :func:`junifer.data.parcellations.list_parcellations`. + :func:`.list_parcellations`. agg_method : str, optional The method to perform aggregation using. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default "mean"). + :func:`.get_aggfunc_by_name` (default "mean"). agg_method_params : dict, optional Parameters to pass to the aggregation function. Check valid options in - :func:`junifer.stats.get_aggfunc_by_name` (default None). + :func:`.get_aggfunc_by_name` (default None). masks : str, dict or list of dict or str, optional The specification of the masks to apply to regions before extracting signals. Check :ref:`Using Masks ` for more details. diff --git a/junifer/markers/temporal_snr/temporal_snr_spheres.py b/junifer/markers/temporal_snr/temporal_snr_spheres.py index 712a1b713..34ec1101a 100644 --- a/junifer/markers/temporal_snr/temporal_snr_spheres.py +++ b/junifer/markers/temporal_snr/temporal_snr_spheres.py @@ -19,7 +19,7 @@ class TemporalSNRSpheres(TemporalSNRBase): ---------- coords : str The name of the coordinates list to use. See - :func:`junifer.data.coordinates.list_coordinates` for options. + :func:`.list_coordinates` for options. radius : float, optional The radius of the sphere in mm. If None, the signal will be extracted from a single voxel. See :class:`nilearn.maskers.NiftiSpheresMasker` @@ -29,7 +29,7 @@ class TemporalSNRSpheres(TemporalSNRBase): the spheres overlap (default is False). agg_method : str, optional The aggregation method to use. - See :func:`junifer.stats.get_aggfunc_by_name` for more information + See :func:`.get_aggfunc_by_name` for more information (default None). agg_method_params : dict, optional The parameters to pass to the aggregation method (default None). diff --git a/junifer/markers/tests/test_markers_base.py b/junifer/markers/tests/test_markers_base.py index 59dbefbd4..ff2d7771c 100644 --- a/junifer/markers/tests/test_markers_base.py +++ b/junifer/markers/tests/test_markers_base.py @@ -99,7 +99,7 @@ def test_base_marker_subclassing() -> None: "element": "elem", "datareader": "dr", }, - } + }, } marker = MyBaseMarker(on=["BOLD"]) output = marker.fit_transform(input=input_) # process diff --git a/junifer/pipeline/registry.py b/junifer/pipeline/registry.py index f0f384ef3..4d482ec69 100644 --- a/junifer/pipeline/registry.py +++ b/junifer/pipeline/registry.py @@ -141,10 +141,7 @@ def build( object_ = klass(**init_params) except Exception as e: raise_error( - msg=( - f"Failed to create {step} ({name}). " - f"Error: {e}" - ), + msg=(f"Failed to create {step} ({name}). " f"Error: {e}"), klass=RuntimeError, exception=e, ) diff --git a/junifer/stats.py b/junifer/stats.py index 06862335e..bf4b133e2 100644 --- a/junifer/stats.py +++ b/junifer/stats.py @@ -28,8 +28,8 @@ def get_aggfunc_by_name( * ``mean`` -> :func:`numpy.mean` * ``std`` -> :func:`numpy.std` * ``trim_mean`` -> :func:`scipy.stats.trim_mean` - * ``count`` -> :func:`junifer.stats.count` - * ``select`` -> :func:`junifer.stats.select` + * ``count`` -> :func:`.count` + * ``select`` -> :func:`.select` func_params : dict, optional Parameters to pass to the function. diff --git a/junifer/storage/base.py b/junifer/storage/base.py index 04cdcb71f..506758c1a 100644 --- a/junifer/storage/base.py +++ b/junifer/storage/base.py @@ -95,8 +95,8 @@ class BaseFeatureStorage(ABC): ------- dict List of features in the storage. The keys are the feature MD5 to - be used in :meth:`junifer.storage.BaseFeatureStorage.read_df` - and the values are the metadata of each feature. + be used in :meth:`.read_df` and the values are the metadata of each + feature. """ raise_error( diff --git a/junifer/storage/hdf5.py b/junifer/storage/hdf5.py index cce9a5fdf..d9d7aa81a 100644 --- a/junifer/storage/hdf5.py +++ b/junifer/storage/hdf5.py @@ -114,8 +114,8 @@ class HDF5FeatureStorage(BaseFeatureStorage): values are found (default True). chunk_size : int, optional The chunk size to use when collecting data from element files in - :meth:`junifer.storage.HDF5FeatureStorage.collect`. If the file count - is smaller than the value, the minimum is used (default 100). + :meth:`.collect`. If the file count is smaller than the value, the + minimum is used (default 100). See Also -------- @@ -262,8 +262,8 @@ class HDF5FeatureStorage(BaseFeatureStorage): ------- dict List of features in the storage. The keys are the feature MD5 to - be used in :meth:`junifer.storage.HDF5FeatureStorage.read_df` - and the values are the metadata of each feature. + be used in :meth:`.read_df` and the values are the metadata of each + feature. """ # Read metadata @@ -496,9 +496,7 @@ class HDF5FeatureStorage(BaseFeatureStorage): ) -> None: """Write processed data to HDF5 (should not be called directly). - This is used primarily in - :func:`junifer.storage.HDF5FeatureStorage.store_metadata` and - ``_store_data``. + This is used primarily in :meth:`.store_metadata` and ``_store_data``. Parameters ---------- diff --git a/junifer/storage/sqlite.py b/junifer/storage/sqlite.py index e511c9e49..5621e8e69 100644 --- a/junifer/storage/sqlite.py +++ b/junifer/storage/sqlite.py @@ -213,8 +213,8 @@ class SQLiteFeatureStorage(PandasBaseFeatureStorage): ------- dict List of features in the storage. The keys are the feature MD5 to - be used in :meth:`junifer.storage.SQLiteFeatureStorage.read_df` - and the values are the metadata of each feature. + be used in :meth:`.read_df` and the values are the metadata of each + feature. """ # Retrieve meta table from storage diff --git a/tools/create_hcp1200_example_dataset.py b/tools/create_hcp1200_example_dataset.py index 5a3bd0637..4aa4044ea 100644 --- a/tools/create_hcp1200_example_dataset.py +++ b/tools/create_hcp1200_example_dataset.py @@ -22,7 +22,7 @@ if __name__ == "__main__": # Set base directory basedir = tmpdir_path / "example_hcp1200" # Create new datalad dataset - dataset = dl.create(path=str(basedir.absolute())) # type: ignore + dataset = dl.create(path=str(basedir.absolute())) # Generate subject directories for sub in range(1, 10): subdir = basedir / f"sub-{sub:02d}" @@ -57,26 +57,15 @@ if __name__ == "__main__": ) # Create subject data directory sub_datadir.mkdir(parents=True) - # Set subject data file sub_datafile = ( sub_datadir - / f"{new_task}_{phase_encoding}.nii.gz" + / f"{new_task}_{phase_encoding}_hp2000_clean.nii.gz" ) # Create subject data file with open(sub_datafile, "w") as f: f.write("placeholder") - if "REST" in task: - # Set subject data file with ICA+FIX - sub_datafile = ( - sub_datadir - / f"{new_task}_{phase_encoding}_hp2000_clean.nii.gz" - ) - # Create subject data file with ICA+FIX - with open(sub_datafile, "w") as f: - f.write("placeholder") - # Save datalad dataset dataset.save(recursive=True) # Add datalad sibling