Warning
This is a draft. Comments are welcomed!
Uploading Data¶
In order to upload a data object, brainlife requires that you supply a project and datatype associated with it. For example, the data we will be uploading–a t1 weighted image–must contain a file called 't1.nii.gz' in order to be successfully stored.
Before following along with this readme, you will need to make your own project on brainlife.io.
Have you made one? Then let's begin:
Querying the Project¶
To search through the list of projects, we can use bl project query
My username is stevengeeky
, so I'll query all of the projects I'm the admin of:
1 2 3 4 5 6 7 8 9 10 |
|
Keep the id in mind for later. To specifically extrapolate the id from the query, install jq
and run something similar to the following (using the previous query as an example):
1 |
|
Which returns 5afc2c8de68fc50028e90820
.
--json
instructs the CLI to output results in JSON format so that jq can parse the output.
Also, if you don't know what to run or how to run something, simply attach --help to the end of any command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Querying Datatype¶
Now, we need a datatype for our data. Since I will be uploading a t1 weighted image, I'll query for the list of datatypes which might match what I want:
1 2 3 4 5 6 7 |
|
The single result returned happens to be exactly what we want. This will be the datatype for our uploaded data.
Uploading Dataset¶
Now, it's time to actually upload our data. I have a file named t1.nii.gz
in a directory called t1/
, and to upload it I need to supply a few things. Let's run bl data upload --help
to figure out what those things are:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
All that is required to upload a data is a directory to upload, a project id, and a datatype id. But you can also supply other options to provide additional information about it, such as applicable datatype tags, search tags, and which session and subject the data is from.
I will upload my data by using the following command, given the id of my project and datatype of my data:
1 2 3 4 5 6 7 8 9 10 |
|
Notice that I supplied --tag
twice to add more than one search tag to my data. This works the same way with datatype_tags
. --meta is optional but you should point to any "sidecar" json if you have one.
You must specify paths to each files/directory for the datatype that you are uploading. For example, for --datatype neuro/anat/t1w
, you must specify --t1
with the file path for your .nii.gz file containing the t1w anatomy. Please refer to the README section for various datatypes on brainlife under datatypes.
1 2 3 4 5 |
|
You can see the process update in real time. When it has finally finished it should output:
1 2 3 |
|
Querying Datasets¶
Now that we've uploaded a data, we can view it by querying the list of data:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Bulk Upload¶
Say we have all files from several subejcts in a single folder (the current folder) with two datafiles, DWI (dffusion-weighted MRI data files) and T1W (t1 weighted MRI, anatomical data files). Say that each subject is either a control (CNTR) or a patient (PTNT).
We will first login on brainlife. Then set the current project variable (project IDs are the hash-numbers indicated on each project web-address on brainlife.io)
We will match the DWI files to the correspondign brainlife.io datatype, which is neuro/dwi. We will also match the T1W files to the corresponding brainlife.io datatype which is neuro/anat/t1w.
We will automatically find the total number of subejcts and for each subject we will push on the brainlife.io platform the T1W and the DWI and match them with the corresponding datatype. The CLI command will run the brainlife.io datatype validator and upload the file, which will magically populate the project online.
A bash script would would look like the following:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Note
You should add --meta if you have any sidecard to go with each dwi/t1
BIDS Upload¶
If you have data organized in a BIDS format, you can upload the entire dataset with a single command.
1 |
|