Skip to content

Exporting Data

There are two common formats of exported data from Flywheel. The first format is to export the data in source DICOM files. The second method is to export the data after BID curation as NIfTI files.

There are pros and cons each file formats, but ultimately, the project demands will dictate the preferred data format. Below describes methods to obtain data from Flywheel in either foramts.

DICOM

Data from a Siemens 3T Prisma scanner, by default, is uploaded to Flywheel in DICOM format. DICOM is a standard file format for medical images and its related information.

When data is exported in DICOM format, the data structure (i.e., folders and subfolders) will be based on Flywheel's data heirarchy.

Group > Project > Subject > Session > Acquisition > File

It is possible to customize the data structure the data is exported into with export templates, but doing so will require using Flywheel's Command-Line Interface (CLI).

Exporting Data via the Web User Interface (UI)

Exporting data via Flywheel's Web UI can be performed at the multiple levels.

  1. Project
  2. Sessions or multiple acquisitions
  3. Single file

Please follow the links to Flywheel's documentation for relevant information and instructions on how to use the web UI for exporting data.

Exporting Data with Flywheel Command-Line Interface (CLI)

The CLI is an additional Flywheel program that can be used from the computer's Command Prompt (Windows) or Terminal (Mac). To install the Flywheel CLI, go to Flywheel's CLI Installation page.

Once the CLI has been installed successfully, you can download the data in DICOM format from the Command Prompt or Terminal.

The main command will take the form:

fw download [optional flags] path/to/data/on/flywheel

Documentation for how to export data as DICOM with Flywheel's CLI can be found here.

Common Commands

Attention

The path/to/data/on/flywheel will be user specific. Please change the paths in the example commands to match with your desired data.

Exporting only DICOM files from a project:

fw download group/project --include dicom

Exporting only DICOM files of one session for a subject:

fw download group/project/subject/session --include dicom

Other file types can be specified by besides DICOM files. Flywheel provides a list of reconized file types here.

Unzipping DICOM Files

Data exported in DICOM format are compressed as zip files for ease when transferring multiple large files. However, it might be easier for some software to load the individual uncompressed DICOM files.

The decompression process is possible from the command line with a few commands.

First, navigate to the project directory.

cd /path/to/project/directory

Next, use the first command to find all *.dicom.zip files in the current and sub directories and unzip the files. If desired, the second line performs the same unzipping process but also deletes the zip file.

find . -name "*.dicom.zip" -execdir unzip {} \; # unzips only
find . -name "*.dicom.zip" -execdir unzip {} \; -delete # unzips and deletes

It is fine to stop at this step if you only want to unzip the compressed files.

However, if it is desired to unnest the uncompressed DICOM files from their compressed directory, execute the following command to move the DICOM files up one directory.

find . -name "*.dcm" -execdir mv {} .. \;

Finally, perform clean up by deleting any empty directories created by the uncompressing process.

find . -type d -empty -delete

These commands can be found compiled in the provided bash script, unzip_dicom.sh. Note the script deletes the compressed DICOM files as the default. The bash script can be called from the command line as such.

$ path/to/unzip_dicom.sh /path/to/compressed/dicom/directories

BIDS

It might be useful for some projects to be exported in BIDS compliant format. This is possible so long as the desired files have been processed with the BIDS Curation Analysis Gear.

When data is exported in BIDS format, the data structure will be based on BIDS Specification.

Project > Subject > Session
        > Modality (anat, fmap, func, dwi)
        > File (*.json, *.nii.gz)

Currently, the only method of exporting data from Flywheel in BIDS format is with the Flywheel CLI.

Exporting Data in BIDS Format with Flywheel CLI

If the CLI has been installed successfully, you can download your data in BIDS format from the Command Prompt or Terminal.

The main command will take the form:

fw export bids [optional flags] --project "project_name" /path/to/destination/folder

The Flywheel's BIDS Export Documentation explains the exporting process additional information and options available through the CLI.

Common Commands

Export an entire project:

fw export bids --project "project_label" /path/to/project_folder

Exporting by session (\ allows for multiline commands):

fw export bids \
    --project "project_label" \
    --session "ses-01" \
    path/to/destination/folder

Exporting by subject:

fw export bids \
    --project "project_label" \
    --subject "sub-01" \
    path/to/destination/folder

Exporting by subject and data types:

fw export bids \
    --project "project_label" \
    --subject "sub-01" \
    --data-type "anat" \
    --data-type "func" \
    path/to/destination/folder

Exporting with DICOM source data files:

fw export bids \
    --project "project_label" \
    --source-data \
    path/to/destination/folder

BIDS Validation

Downloading the data from Flywheel does not guarantee that it is up-to-date with the latest BIDS specification. The BIDS standard updates regularly, which causes software, such as the BIDS Curation Gear, based on a previous BIDS version to lag behind in updating.

Therefore, it is good practice to use the BIDS Validator to ensure compliance with the latest BIDS version. There are multiple implementations of the validator (read the validator's documentation), but the online version is probably the easiest and fastest to use.


Last update: February 23, 2022