File Conversion Tools
Installing Conversion Software
For converting anatomical MR files to BIDS, we will use dcm2niix
, and for converting PET files to BIDS, we will use PET2BIDS
. To use PET2BIDS
, we will first install Python and conda (although PET2BIDS can also be used with MATLAB - see the full documentation for details).
Note: For Windows users, many of these tools can be run with Windows directly, but with some difficulty. It is easier to run everything using Linux directly through the Windows Subsystem for Linux (WSL).
WSL (Windows users)
I recommend using WSL with Ubuntu 22.04, because FreeSurfer has not yet been made available for Ubuntu 24.04 (which is the default WSL distribution).
-
Open PowerShell as Administrator - Search for PowerShell in the Start menu - Right-click and select "Run as administrator"
-
Install WSL with Ubuntu
This command installs WSL with Ubuntu as the default distribution. The system will require a restart.wsl --install -d Ubuntu-22.04
-
After restart, Ubuntu will finish setup - When prompted, create a username and password for your Linux distribution - This doesn't need to match your Windows credentials
-
To open Ubuntu, search for Ubuntu in the Start menu
Note: To understand where things are using WSL, your local drives are listed as mounted drives. You can find them in the /mnt
folder. So the contents of your C:\ are at /mnt/c/
. Note that for network drives, this can be a bit of a pain. I recommend doing processing locally and copying the files later to the network drive, but if you do wish to mount the network drive directly, you can follow the guide under BMIC > Getting Started > Mounting Network Drives (and follow the instructions for Linux).
Python
-
Install Python
- Download the latest Python installer from python.org
- Run the installer
- Important: Check "Add Python to PATH"
- Select "Install Now"
-
Install Miniconda
- Download Miniconda from conda.io
- Run the installer
- Accept the license agreement
- Select "Just Me" when asked who to install for
- Choose a destination folder (the default is fine)
- For Advanced Options, you can leave them as they are
- Click "Install"
-
For future steps, when using the terminal, use the "Anaconda Prompt". You will find it in your start menu.
-
In Anaconda Prompt, create a new virtual environment for working with PET BIDS data
conda create --name PETBIDS python=3.10 conda activate PETBIDS
-
Install Python (if not already installed)
- Open Terminal
- Update package lists and install Python:
sudo apt update sudo apt install python3 python3-pip python3-venv
-
Install Miniconda
- Download Miniconda:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
- Make the installer executable:
chmod +x Miniconda3-latest-Linux-x86_64.sh
- Run the installer:
./Miniconda3-latest-Linux-x86_64.sh
- Follow the prompts, accept the license agreement
- Allow the installer to initialize Miniconda
- Download Miniconda:
-
Create a new virtual environment for working with PET BIDS data
conda create --name PETBIDS python=3.10 conda activate PETBIDS
PET2BIDS
PET2BIDS is a well-validated tool for converting ecat7 (.v
) and DICOM (.dcm
) files to BIDS files.
Activate your PETBIDS environment. Remember that in Windows, you need to be using the "Anaconda Prompt".
conda activate PETBIDS
And then we can proceed to install the PET2BIDS software
pip install pypet2bids
The full package documentation can be found here.
dcm2niix
dcm2niix can also be installed using conda
into your PETBIDS environment as follows:
conda activate PETBIDS
conda install -c conda-forge dcm2niix
To check if dcm2niix is installed correctly:
- Open a terminal (Command Prompt, Terminal, etc.)
- Type
dcm2niix -h
and press Enter - You should see the help message with usage instructions
Docker
Docker is a tool for running software within a containerized environment. This means that all the dependencies are included within the docker container, and the software can be run without installing anything. BIDS Apps are often containerised within docker or singularity containers.
Docker works best in Linux, and can be a bit of a pain in Windows. For running Docker in Windows, it's generally easier to run it within WSL (Windows Subsystem for Linux) to simulate a Linux environment.
-
Open PowerShell as Administrator - Search for PowerShell in the Start menu - Right-click and select "Run as administrator"
-
Install WSL with Ubuntu
This command installs WSL with Ubuntu as the default distribution. The system will require a restart.wsl --install -d Ubuntu-22.04
-
After restart, Ubuntu will finish setup - When prompted, create a username and password for your Linux distribution - This doesn't need to match your Windows credentials
-
Update your Ubuntu installation
sudo apt update && sudo apt upgrade -y
Then follow the instructions for installing on Linux
- Install prerequisites
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
-
Follow the instructions here to: i. Set up Docker's apt repository. ii. Install the Docker packages.
-
Check that the installation was successful by running the
hello-world
containersudo docker run hello-world
-
Follow the post-install steps:
sudo groupadd docker sudo usermod -aG docker $USER
-
Log out and log in again (or restart)
-
Test that you can now run docker commands without
sudo
docker run hello-world