Skip to content

Commit e5c9f2a

Browse files
authored
Update documentation (#8)
1 parent dbfe3a6 commit e5c9f2a

7 files changed

Lines changed: 68 additions & 56 deletions

File tree

README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
1-
# ConFixel: Moved to ModelArrayIO
1+
# ModelArrayIO
22

3-
ConFixel has moved beyond fixels and handles a lot of other modalities.
4-
It also got optimized!
5-
[Going forward, ConFixel is now ModelArrayIO.](https://pennlinc.github.io/ModelArrayIO/).
6-
This repository will be left here because the URL is in the publication.
3+
**ModelArrayIO** is a Python package that converts between neuroimaging formats (fixel `.mif`, voxel NIfTI, CIFTI-2 dscalar) and the HDF5 (`.h5`) layout used by the R package [ModelArray](https://pennlinc.github.io/ModelArray/). It can also write ModelArray statistical results back to imaging formats.
74

5+
**Relationship to ConFixel:** The earlier project [**ConFixel**](https://github.com/PennLINC/ConFixel) is superseded by ModelArrayIO. The ConFixel repository is retained for history (including links from publications) and will be archived; new work should use this repository.
86

9-
`ConFixel` is companion converter software for [ModelArray](https://pennlinc.github.io/ModelArray/) for converting data back and forth from the HDF5 file format.
7+
Documentation for installation and usage: [ModelArrayIO on GitHub](https://github.com/PennLINC/ModelArrayIO#installation) (this README). For conda, HDF5 libraries, and installing the ModelArray R package, see the ModelArray vignette [Installation](https://pennlinc.github.io/ModelArray/articles/installations.html).
108

119
<p align="center">
1210

1311
![Overview](overview_structure.png)
1412

1513
</p>
1614

17-
`ConFixel` software includes three converters: `ConFixel` for fixel-wise data (`.mif`), `ConVoxel` for voxel-wise data (NIfTI) and `ConCIFTI` for CIFTI-2 dscalar files. Each converter converts between the original image format and the HDF5 file format (`.h5`) that ModelArray uses.
15+
ModelArrayIO provides three converter areas, each with import and export commands:
1816

19-
Below lists the commands in each converter. After [installation](#installation), these commands can be directly called in a terminal console.
17+
After [installation](#installation), these commands are available in your terminal:
2018

21-
* `ConFixel` converter for fixel-wise data (MRtrix image format `.mif`):
22-
* `.mif` --> `.h5`: command `confixel`
23-
* `.h5` --> `.mif`: command `fixelstats_write`
24-
* `ConVoxel` converter for voxel-wise data (NIfTI):
25-
* NIfTI --> `.h5`: command `convoxel`
26-
* `.h5` --> NIfTI: command `volumestats_write`
27-
* `ConCIFTI` converter for greyordinate-wise data (CIFTI-2):
28-
* CIFTI-2 --> `.h5`: command `concifti`
29-
* `.h5` --> CIFTI-2: command `ciftistats_write`
19+
* **Fixel-wise** data (MRtrix `.mif`):
20+
* `.mif` `.h5`: `confixel` (CLI name kept for compatibility with earlier ConFixel workflows)
21+
* `.h5` `.mif`: `fixelstats_write`
22+
* **Voxel-wise** data (NIfTI):
23+
* NIfTI `.h5`: `convoxel`
24+
* `.h5` NIfTI: `volumestats_write`
25+
* **Greyordinate-wise** data (CIFTI-2):
26+
* CIFTI-2 `.h5`: `concifti`
27+
* `.h5` CIFTI-2: `ciftistats_write`
3028

3129
## Installation
3230
### Install dependent software MRtrix (only required for fixel-wise data `.mif`)
33-
When converting fixel-wise data's format (`.mif`), converter `ConFixel` uses function `mrconvert` from MRtrix, so please make sure MRtrix has been installed. If it's not installed yet, please refer to [MRtrix's webpage](https://www.mrtrix.org/download/) for how to install it. Type `mrview` in the terminal to check whether MRtrix installation is successful.
31+
For fixel-wise `.mif` conversion, the `confixel` / `fixelstats_write` tools use MRtrix `mrconvert`. Install MRtrix from [MRtrixs webpage](https://www.mrtrix.org/download/) if needed. Run `mrview` in the terminal to verify the installation.
3432

35-
If your input data is voxel-wise data or CIFTI (greyordinate-wise) data, you can skip this step.
33+
If your data are voxel-wise or CIFTI only, you can skip this step.
3634

37-
### Install `ModelArrayIO` software
38-
Before installing ModelArrayIO software, you may want to create a conda environment - see [here](https://pennlinc.github.io/ModelArray/articles/installations.html) for more. If you installed MRtrix in a conda environment, you can directly install ConFixel software in that environment.
35+
### Install ModelArrayIO
36+
You may want a conda environment first—see [ModelArray: Installation](https://pennlinc.github.io/ModelArray/articles/installations.html). If MRtrix is installed in that environment, install ModelArrayIO in the same environment.
3937

40-
You can install `ModelArrayIO` software from `GitHub`:
38+
Install from GitHub:
4139

4240
``` console
4341
git clone https://github.com/PennLINC/ModelArrayIO.git
4442
cd ModelArrayIO
4543
pip install . # build via pyproject.toml
4644
```
4745

48-
If you are a developer, and if there is any update in the source code locally, you may update the installation with an editable install:
46+
Editable install for development:
4947

5048
``` console
5149
# From the repository root
5250
pip install -e .
5351
```
5452

55-
Alternatively, if you have `hatch` installed, you can build wheels/sdist locally:
53+
With `hatch` installed, you can build wheels/sdist locally:
5654

5755
``` console
5856
hatch build
5957
pip install dist/*.whl
6058
```
6159

6260
## How to use
63-
We provide [walkthrough for how to use `ConFixel` for fixel-wise data](notebooks/walkthrough_fixel-wise_data.md), and [walkthrough for `ConVoxel` for voxel-wise data](notebooks/walkthrough_voxel-wise_data.md).
61+
We provide a [walkthrough for fixel-wise data](notebooks/walkthrough_fixel-wise_data.md) (`confixel` / `fixelstats_write`) and a [walkthrough for voxel-wise data](notebooks/walkthrough_voxel-wise_data.md) (`convoxel` / `volumestats_write`).
6462

65-
As `ConFixel` software is usually used together with [ModelArray](https://pennlinc.github.io/ModelArray/), we also provide [a combined walkthrough](https://pennlinc.github.io/ModelArray/articles/walkthrough.html) of ConFixel + ModelArray with example fixel-wise data.
63+
Together with [ModelArray](https://pennlinc.github.io/ModelArray/), see the [combined walkthrough](https://pennlinc.github.io/ModelArray/articles/walkthrough.html) with example fixel-wise data (ModelArray + ModelArrayIO).
64+
65+
CLI help:
6666

67-
You can also refer to `--help` for additional information:
6867
``` console
6968
confixel --help
7069
```
71-
You can replace `confixel` with other commands in ConFixel.
70+
71+
Use the same pattern for `convoxel`, `concifti`, `fixelstats_write`, `volumestats_write`, and `ciftistats_write`.
7272

7373
## Storage backends: HDF5 and TileDB
7474

notebooks/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Walkthrough for different imaging data types
22

3-
* [Walkthrough for fixel-wise data conversion](walkthrough_fixel-wise_data.md) using converter `ConFixel`
4-
* [Walkthrough for voxel-wise data conversion](walkthrough_voxel-wise_data.md) using converter `ConVoxel`
3+
* [Walkthrough for fixel-wise data conversion](walkthrough_fixel-wise_data.md) (`confixel` / `fixelstats_write` in ModelArrayIO)
4+
* [Walkthrough for voxel-wise data conversion](walkthrough_voxel-wise_data.md) (`convoxel` / `volumestats_write` in ModelArrayIO)

notebooks/walkthrough_fixel-wise_data.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Walkthrough for fixel-wise data conversion
22

3-
For fixel-wise data, we use converter `ConFixel` to convert between fixel-wise data format `.mif` and the HDF5 file format (`.h5`) that ModelArray uses. At this point, we expect you have followed the [Installation guide](../README.md#installation) and installed `ConFixel` software and dependent software `MRtrix` which is needed for fixel-wise data.
3+
For fixel-wise data, use the **`confixel`** command (from the **ModelArrayIO** Python package) to convert between MRtrix `.mif` files and the HDF5 file format (`.h5`) that ModelArray uses. This guide assumes you followed the [installation guide](../README.md#installation), installed **ModelArrayIO**, and installed **MRtrix** for fixel-wise workflows.
44

55
## Prepare data
66

@@ -57,10 +57,10 @@ Notes:
5757
* File names in column `source_file` in CSV file v.s. the actual file names on disk;
5858
* Scalar name e.g., "FD" in column `scalar_name` in CSV file v.s. what you will specify when using functions in `ModelArray`;
5959

60-
For this case, when running ConFixel creating hdf5 fixel-wise data, argument **--relative-root** should be "/home/username/myProject/data"
60+
For this case, when running `confixel` to create HDF5 fixel-wise data, argument **--relative-root** should be "/home/username/myProject/data"
6161

6262

63-
## Run ConFixel
63+
## Run `confixel` and `fixelstats_write`
6464
### Convert .mif files to an HDF5 (.h5) file
6565
Using above described scenario as an example, for FD dataset:
6666
``` console
@@ -72,7 +72,6 @@ confixel \
7272
--relative-root /home/username/myProject/data \
7373
--output-hdf5 FD.h5
7474
```
75-
<!-- ^ above is tested -->
7675

7776
Now you should get the HDF5 file "FD.h5" in folder "/home/username/myProject/data". You may use [ModelArray](https://pennlinc.github.io/ModelArray/) to perform statistical analysis.
7877

@@ -100,16 +99,11 @@ confixel --help
10099
fixelstats_write --help
101100
```
102101

103-
<!--TODO: after update please test out: use conda + terminal command `confixel` and `fixelstats_write`; Still using case above as an example -->
104-
<!-- fixelstats_write: can be tested out with existing results; otherwise have to run for all fixels.. -->
105-
106102

107103
## Other notes
108-
### ConFixel: convert from `.h5` to `.mif`
104+
### Export from `.h5` to `.mif` (`fixelstats_write`)
109105
#### Existing output folder and output images
110106
⚠️ ⚠️ WARNING ⚠️ ⚠️
111-
* If there are existing images in the output folder and they have the same filenames as those to be saved, the existing images won't be overwritten. This is because in function `confixel.fixels.nifti2_to_mif()`, we did not turn on `-force` in `mrconvert` (i.e., output files won't be overwritten).
112-
* In addition, if the output folder already exists, `ConFixel` will not delete it or create a new one. You will only get a message saying "WARNING: Output directory exists". Therefore, any existing files in the output folder will be kept as it is.
113-
* So, if the output folder already exists, you may consider manually deleting it before using `ConFixel` to save new images.
114-
115-
<!--- TODO: above words: to be confirmed! --->
107+
* If there are existing images in the output folder and they have the same filenames as those to be saved, the existing images won't be overwritten. This is because in `modelarrayio.fixels.nifti2_to_mif()`, we did not turn on `-force` in `mrconvert` (i.e., output files won't be overwritten).
108+
* In addition, if the output folder already exists, `fixelstats_write` will not delete it or create a new one. You will only get a message saying "WARNING: Output directory exists". Therefore, any existing files in the output folder will be kept as it is.
109+
* So, if the output folder already exists, you may consider manually deleting it before using `fixelstats_write` to save new images.

notebooks/walkthrough_voxel-wise_data.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Walkthrough for voxel-wise data conversion
22

3-
For voxel-wise data, we use converter `ConVoxel`. In general, `ConVoxel` is very similar to converter `ConFixel`.
3+
For voxel-wise data, use the **`convoxel`** command from **ModelArrayIO**. In general, the voxel workflow is very similar to the fixel workflow (`confixel`).
44

55
## Prepare data
66
To convert (a list of) voxel-wise data from NIfTI format to .h5 format, you need to prepare a cohort CSV file that provides basic information for all NIfTI files you want to include. We recommend that, for each scalar (e.g. FA), prepare one .csv file, and thus getting one .h5 file.
77

8-
In addition, different from converter `ConFixel`, you also need to provide these image files:
8+
In addition, unlike the fixel pipeline, you also need to provide these image files:
99
* one group mask: Only voxels within the group mask will be kept during conversion to .h5 file.
1010
* subject-specific masks (i.e., individual masks): This takes the inconsistent boundary of subject-specific images into account. After conversion, for each subject's scalar mage, voxels outside the subject-specific mask will be set to `NaN`. `ModelArray` will then check if each voxel has sufficient number of subjects to get reliable statistics (see argument `num.subj.lthr.abs` and `num.subj.lthr.rel` in Model fitting functions, e.g., [`ModelArray.lm()`](https://pennlinc.github.io/ModelArray/reference/ModelArray.lm.html)).
1111
* If you don't have subject-specific masks, that's fine; you can use group mask instead (see below for how to achieve this in .csv file).
@@ -56,13 +56,13 @@ Notes:
5656
* File names in columns `source_file` and `source_mask_file` in CSV file v.s. the actual file names on disk;
5757
* Scalar name e.g., "FA" in column `scalar_name` in CSV file v.s. what you will specify when using functions in `ModelArray`;
5858

59-
For this case, when running ConVoxel, argument `--relative-root` should be `/home/username/myProject/data`
59+
For this case, when running `convoxel`, argument `--relative-root` should be `/home/username/myProject/data`
6060

61-
## Run ConVoxel
61+
## Run `convoxel` and `volumestats_write`
6262
### Convert NIfTI files to an HDF5 (.h5) file
6363
Using above described scenario as an example, for FA dataset:
6464
``` console
65-
# first, activate conda environment where `ConFixel` is installed: `conda activate <env_name>`
65+
# first, activate conda environment where ModelArrayIO is installed: `conda activate <env_name>`
6666
convoxel \
6767
--group-mask-file group_mask.nii.gz \
6868
--cohort-file cohort_FA.csv \
@@ -76,7 +76,7 @@ Now you should get the HDF5 file "FA.h5" in folder "/home/username/myProject/dat
7676
After running `ModelArray` and getting statistical results in FA.h5 file (say, the analysis name is called "mylm"), you can use `volumestats_write` to convert results into a list of NIfTI files in a folder specified by you.
7777

7878
``` console
79-
# first, activate conda environment where software `ConFixel` is installed: `conda activate <env_name>`
79+
# first, activate conda environment where ModelArrayIO is installed: `conda activate <env_name>`
8080
volumestats_write \
8181
--group-mask-file group_mask.nii.gz \
8282
--cohort-file cohort_FA.csv \
@@ -99,12 +99,12 @@ volumestats_write --help
9999
```
100100

101101
## Other notes
102-
### ConVoxel: convert from `.h5` to NIfTI
102+
### `volumestats_write`: convert from `.h5` to NIfTI
103103
#### Existing output folder and output images
104104
⚠️ ⚠️ WARNING ⚠️ ⚠️
105-
* If the output folder already exists, `ConVoxel` will not delete it or create a new one. You will only get a message saying "WARNING: Output directory exists". Therefore, if there were existing files in the output folder, and they are not part of the current list of images to be saved (e.g., results to be saved were changed, but the output folder name was not changed), these files will be kept as it is and won't be deleted. <!--- confirmed with toy data, 3/9/2023 -->
106-
* However, for existing files which are still part of the current list to be saved, they will be replaced. This is different from current implementation of `ConFixel` converter for fixel-wise data. <!--- confirmed with toy data, 3/9/2023 -->
107-
* So to avoid confusion and better for version controls, if the output folder already exists, you might consider manually deleting it before using `ConVoxel` to save new images.
105+
* If the output folder already exists, `volumestats_write` will not delete it or create a new one. You will only get a message saying "WARNING: Output directory exists". Therefore, if there were existing files in the output folder, and they are not part of the current list of images to be saved (e.g., results to be saved were changed, but the output folder name was not changed), these files will be kept as it is and won't be deleted.
106+
* However, for existing files which are still part of the current list to be saved, they will be replaced. This differs from the fixel-wise `fixelstats_write` behavior (which does not overwrite existing `.mif` outputs via `mrconvert` without `-force`).
107+
* So to avoid confusion and better for version controls, if the output folder already exists, you might consider manually deleting it before using `volumestats_write` to save new images.
108108

109109

110110
### Image of number of observations used

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "modelarrayio"
7-
description = "ConFixel (python) is companion converter software for ModelArray for converting data back and forth from the HDF5 file format"
7+
description = "ModelArrayIO: convert fixel, voxel, and greyordinate neuroimaging data to/from HDF5 for the ModelArray R package"
88
readme = "README.md"
99
requires-python = ">=3.11"
1010
license = { file = "LICENSE" }
@@ -42,6 +42,7 @@ doc = [
4242
"sphinx>=6.2.1",
4343
"myst-parser>=2",
4444
"sphinx-argparse",
45+
"sphinx-copybutton",
4546
"sphinx_rtd_theme",
4647
"sphinxcontrib-apidoc",
4748
"sphinxcontrib-bibtex",

test/data_voxel_toy/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
This is a toy voxel-wise dataset for testing ConVoxel.
1+
This is a toy voxel-wise dataset for testing ModelArrayIO’s voxel pipeline (`convoxel` / `volumestats_write`).
22
* It was generated using scripts in [ModelArray_tests](https://github.com/PennLINC/ModelArray_tests) GitHub repository.
3-
* Using scripts in folder `testdata_ConFixel` there.
3+
* Using scripts in folder `testdata_ConFixel` there (historical folder name from the ConFixel era).
44
* It includes n=20 voxel-wise data with individual masks and a group mask.
55
* Each voxel-wise image has random values in a center ball, and may or may not have values around this ball, making individual masks different among all subjects.
66
* The values are between 0-1.

uv.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)