'command not found' in Data2Bids package

Hi there!

I am a beginner in both Linux and the analysis of neuroimaging data.
I have a bunch of .nii files which I wish to convert to the BIDS format. I decided to try the “data2bids” package, which seems to be the perfect option for this.

I installed the package using the command that was mentioned on their Github page ( pip3 install data2bids), which installed the package on my Linux machine.

Afterward, I created a config.json file which I placed in my current directory where all my .nii files are, just as was mentioned on the Github tutorial of this package GitHub - SIMEXP/Data2Bids: Reorganize fmri files to make them BIDS compliant.

Unfortunately, once I ran this package:

cd myFmriData
data2bids

In my terminal, where myFmriData is the directory with all the .nii files and the config.json, I received “command not found” error. I have tried to run the package from its installation place, to install the package in the same folder (thinking that maybe it is not able to find it), but nothing seems to work.

Has anyone managed to get this package to work and may have any advice?

Have you tried installing the data2bids using pip3? pip install data2bids (if using conda or some virtualenv) or pip install --user data2bids (if using system python)

1 Like

Thanks a lot! I have actually figured out my problem and I was thinking that I can just write here the solution in case any other users may face a similar issue: this is quite a general Linux thing (but me being a complete beginner I had no idea).

The way I understand it - in this package, the only thing that you need to do is to cd to a directory where the files are stored, and then use the data2bids call. However, you have to make sure that you tell Linux where to actually look for this package, and the way to do it if you want to call globally any package is to add it to PATH.

So, I would say that for anyone that has issues and has a similar error message there are three steps I have done to fix things:

  1. check that the package installation worked, using pip3 install
  2. check that you are actually running the right Python version (version 3)
  3. finally, add the package to the PATH

This is what I understand at least… and now it has worked! :slight_smile:

Glad you found a solution.

For the future, if you would like to run it without adding to your PATH, you can do so in one of 2 ways:

  1. Since it’s a python script, you can call it using the python command, like so: python /home/hamilton/where_i_put_programs/data2bids_folder/data2bids
    • As an aside, you can run shell scripts in a similar way, bash <my_bashscript>, sh <my_generic_shellscript>, tcsh <my_tcshscript>, etc.
  2. If you have execution permission for the data2bids script, you can simply run it by typing its full path: /home/hamilton/where_i_put_programs/data2bids_folder/data2bids (this applies to all files)
    • If you would like to run scripts this way, they MUST have a shebang at the top of the script (e.g. #!/bin/bash or #!/usr/bin/env bash for bash scripts)
    • As an aside, you do not have to always type the full path. You can type in a relative path to the program or script.
      • E.g. say you were to cd /home/hamilton/where_i_put_programs/data2bids_folder/, you could type in ./data2bids (./ means “in the current directory”)
1 Like

Also glad you found a solution, as there are few solutions out there that can convert existing nifti datset into BIDS. In case data2bids is not working for anyone, you can also give the nibabel plugin of bidscoin a try – BIDScoin has a GUI and is designed with non-programmers in mind (disclaimer, I’m the main author of BIDScoin ;-))

1 Like