Skip to content
Convert tractography studies from mrtrix into dicom for use in navigation software
Python
Branch: master
Clone or download
Latest commit 9c1eaa7 Sep 10, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Pics added screenshot Sep 10, 2019
bin copyright notices Sep 5, 2019
karawun some extra exports Sep 5, 2019
tests copyright notices Sep 5, 2019
.gitignore a git ignore Sep 5, 2019
LICENSE copyright notices Sep 5, 2019
Readme.md added screenshot Sep 10, 2019
requirements.txt Create repo Sep 2, 2019
setup.py Create repo Sep 2, 2019

Readme.md

Karawun

Brainlab screenshot

Introduction

Karawun converts the results of a diffusion MRI tractography study, as might be used for surgical planning, to a form that is readable by the Brainlab software suite.

The planning results will consist of a set of co-registered nifti images (for example T1, FA, contrast enhanced T1 etc) and associated tract files created using the mrtrix3 tools. Karawun converts the nifti images to dicom images and the tck files to the dicom object format used by Brainlab to represent tracts produced by the internal tracking tool.

Tracts generated by mrtrix3 can thus be used in Brainlab in the same way as tracts generated by Brainlab. This allows you to experiment with your favourite diffusion sequence or post processing method and visualize the results in the planning suite.

Karawun is a grass used as a source of fibre by Aboriginal tribes in south-eastern Australia.

Quick Installation

Karawun is a python package that can be installed using various standard python options. It is recommended that some form of virtual environment is used to isolate karawun and its dependencies from other packages. Installation with miniconda is illustrated below:

Miniconda

  1. Install miniconda for python 3.7

  2. Add package channels:

    conda config --append channels conda-forge \
    --append channels anaconda \
    --append channels SimpleITK
  3. Create a conda environment (using a name of your own choice) and install the dependencies:

    conda create --name KarawunEnv --file https://github.com/DevelopmentalImagingMCRI/karawun/raw/master/requirements.txt
  4. Activate the environment:

    conda activate KarawunEnv
  5. Install karawun (internet access required)

    pip install git+https://github.com/DevelopmentalImagingMCRI/karawun.git@master
  6. Test the installation by running the main script:

    importTractography -h

    This will produce the help information if the installation was successful.

Subsequent uses of karawun only require the conda activate KarawunEnv step.

See below for recommended testing procedure.

Using

The simplest way of using karawun is via the importTractograpy command, as follows:

importTractography --dicom-template path/to/a/dicom --nifti T1.nii.gz fa.nii.gz --tract-files left_cst.tck right_cst.tck -o path/to/output/folder

Explanation

The dicom template is a dicom file from which dicom tags are copied, including all patient information. Ideally this dicom file should be one of the originals from which the nifti files were derived. All patient, physician and institutional details are copied from this template. A single dicom template file is required. A single, anonymised, dicom is provided with the testing data (see below), that may be appropriate for other testing purposes, if you do not have original dicoms available.

The nifti files are the volume images that will be converted to dicom images. They are assumed to be co-registered, as would typically be the case for multiple nifti files used in a common image processing pipeline. The conversion process creates a dicom "frame of reference" to which all volume images belong. Brainlab requires that the user accept this registration.

The tract files are the mrtrix .tck files that need to be displayed in Brainlab. The conversion of these files creates the dicom fibre object format that can be viewed as a 3D object in Brainlab.

The converted dicoms are placed in the output folder. Separate subfolders are created for each nifti file and each tck file.

The input file names are used in various dicom description tags.

The frame of reference is based on the first nifti file in the argument list. Thus the Brainlab "quick viewer" will only allow tracts to be overlaid on that image. Accepting the registration will allow all display combinations.

Typical workflow

A typical workflow involves extracting dicom images from the scanner system, converting them to nifti formats and peforming image processing steps using a range of approaches. Examples include co-registration, tissue classification, brain extraction, activation detection, distortion correction, etc with tools like FSL, FreeSurfer and SPM as well as diffusion tractography using mrtrix. The resulting dataset is then converted to dicom ready for import.

We do not attempt to make the new dicoms align with the original dicoms from which the nifti were derived. Always treat the images derived from the external workup as a new and independent set of data.

We anonymise dicoms before import to Brainlab (using gdcm ) to avoid any chance of overwriting other patient data. In theory, copying tags from an original dicom will make the converted dicoms appear to derive from the correct patient. Please test very thoroughly before relying on this facility.

Longer install, with testing (recommended)

  1. Create and activate an environment, as above, then download the package sources OR fetch via git:

    git clone https://github.com/DevelopmentalImagingMCRI/karawun.git
  2. Install the dependencies

    cd karawun
    conda install --name KarawunEnv --file requirements.txt
  3. Run the test:

    python -m pytest -s tests/

This test uses some data distributed with the package. A successful result is indicated by 1 passed and 1 skipped test. Success means that the dicom files created on your system are identical to those created on the development system. The test destination is displayed as the test is run.

Problems/Requests

Please use the github issue tracker to ask questions or report problems.

Licensing

Karawun is distributed under the Apache License 2.0

Contributors

Richard Beare, Joseph Yang, Chris Adamson, Andrew Perry.

You can’t perform that action at this time.