This application converts tractography files from the .tck
format to the .trk
format. It uses a reference anatomy image in NIfTI format to ensure proper alignment.
- Input:
.tck
tractography file(s) and a reference anatomy image (.nii
or.nii.gz
). - Output: Corresponding
.trk
tractography file(s). - Skips non-TCK files and optionally overwrites existing TRK files.
- Supports multiple tractography files in a single execution.
Gabriele Amorosino ([email protected])
You can run this app on the Brainlife.io platform, which provides cloud computing resources for neuroimaging workflows. Both inputs and outputs are managed directly on the Brainlife.io platform.
- Navigate to the Brainlife.io platform.
- Locate the TCK to TRK Converter app in the Apps section.
- Click the "Execute" tab and specify the required dataset inputs (an anatomy NIfTI file and one or more TCK tractography files).
- Submit the job and wait for the results.
- Install the Brainlife CLI by following the instructions at Brainlife CLI Installation.
- Log in to the CLI with your Brainlife.io credentials:
bl login
- Run the app with the following command:
Replace
bl app run --id <app_id> --project <project_id> --input t1w:<t1w_object_id> --input tck:<tck_object_id>
<app_id>
,<project_id>
,<t1w_object_id>
, and<tck_object_id>
with the appropriate identifiers.
- Python installed on your system.
- Required Python libraries:
nibabel
,argparse
. Install them using pip:pip install nibabel argparse
Clone the repository to your local machine:
git clone https://github.com/gamorosino/app-trc2trk
cd app-trc2trk
Run the script using the following command:
python tck2trk.py <anatomy_image.nii> <tractogram1.tck> [<tractogram2.tck> ...]
-f
,--force
: Overwrite existing TRK files.
python tck2trk.py anatomy.nii.gz tract1.tck tract2.tck -f
This will:
- Load the anatomy reference (
anatomy.nii.gz
). - Convert
tract1.tck
andtract2.tck
intotract1.trk
andtract2.trk
, overwriting existing TRK files if any.
- Singularity installed and accessible.
-
Clone the repository:
git clone https://github.com/gamorosino/app-trc2trk cd app-trc2trk
-
Create a
config.json
file in the repository directory, specifying the required input paths. Example:{ "tck": "/path/to/tract.tck", "t1w": "/path/to/t1w.nii.gz" }
-
Run the script:
./main
This will:
- Use the Singularity container to execute the script and convert the TCK file to a TRK file.
- Python 3.6+
- Libraries:
nibabel
argparse
Install dependencies with:
pip install -r requirements.txt
- Singularity installed and accessible.
The converted TRK files are saved in the same directory as the input TCK files, with the same filename but a .trk
extension.
- Non-TCK files are skipped automatically.
- Use the
-f
flag to overwrite output files if they already exist.
Based on the script of Marc-Alexandre Côté (https://gist.github.com/MarcCote/ea6842cc4c3950f7596fc3c8a0be0154).