# Data handling tools¶

This page describes data handling tools provided by Clinica for BIDS and CAPS compliant datasets. These tools provide easy interaction mechanisms with datasets, including generating subjects list or merging all tabular data into a single tsv for analysis with external statistical software.

## Generate the list all subjects and visits of a given dataset¶

Create a .tsv file with two columns (participant_id and session_id) that contains the list of visits for each subject.

clinica iotools create-subjects-visits bids_directory output_directory [-on]

where:

• bids_directory: input folder of a BIDS compliant dataset
• output_directory: output folder
• on, -- output_name (Optional): if not specified, the default name for the file created will be subject_sessions_list.tsv.

Here is an example of the file generated:

participant_id     session_id
sub-01             ses-M0
sub-02             ses-M24
sub-03             ses-M24
...

NB: the format of the subject id and the session id follows the BIDS standard.

Example

clinica iotools create-subjects-visits /Home/ADNI_BIDS/ /Home/


## Check missing modalities for each subject¶

Starting from a BIDS compliant dataset, this command creates:

1. One .tsv file for each session available with the list of the modalities found for each subject. The name of the files produced will be <prefix>_ses-<session_id>.tsv.
2. One .txt file containing the number and the percentage of modalities missing for each session. The name of the files produced will be <prefix>_summary.txt.

If no value for <prefix> is specified by the user, the default will bemissing_mods.

clinica iotools check-missing-mods bids_directory output_directory [-op]

where:

• bids_directory: input folder of a BIDS compliant dataset
• output_directory: output folder
• -op, --output_prefix (Optional): prefix used for the name of the output files. If not specified the default value will be missing_mods

If, for example, only the session M0 is available and the parameter -op is not specified, the command will create the files:

• missing_mods_ses-M0.tsv
• missing_mods_summary.txt.

The content of missing_mods_ses-M0.tsv will look like:

participant_id  FLAIR  T1w
sub-01           1     1
sub-02           1     0
sub-03           1     0


Where the column participant_id contains all the subjects found and the following columns correspond to the list of all the modalities available for the given dataset. The availability is expressed by a boolean value. The nomenclature of the modalities tries to follow, as much as possible, the one proposed by the BIDS standard.

Examples

clinica iotools check-missing-mods/Home/ADNI_BIDS/ /Home/
clinica iotools check-missing-mods/Home/ADNI_BIDS/ /Home/ -op new_name


## Merge all tsv files of a BIDS dataset¶

Merge all .tsv of a BIDS compliant dataset in a single file. BIDS datasets are composed of multiple tsv files for the different subjects and session. While this has some advantages, it may not be convenient for performing statistical analysis (with external statistical software for instance). This command thus allows to merge all .tsv files into a single larger .tsv file.

clinica iotools merge-tsv bids_directory  output_directory

where:

• bids_directory: input folder of a BIDS compliant dataset
• output_directory: output folder

If not specified, the default name for the file created will be merge-tsv.tsv. The output file will contain one row for each visit, as shown in the following example:

participant_id    session_id    date_of_birth   fMRI_performed ...
sub-01              ses-M00        25/04/41           Y
sub-01              ses-M18        25/04/41           N
sub-02              ses-M00        09/01/91           Y
…


Example

clinica iotools merge-tsv /Home/ADNI_BIDS  /Home/merge-tsv.tsv


## Conversion of publicly available neuroimaging datasets to BIDS¶

A special page is dedicated to the conversion of several publicly available neuroimaging datasets to BIDS.