Uploading Brain Data with the CLI
The BrainMaps CLI provides powerful tools for uploading brain scan data to the platform. This guide covers the various methods and options for uploading different types of brain scan files.
Supported File Types
The BrainMaps CLI supports these file formats:
.nii- NIfTI format (Neuroimaging Informatics Technology Initiative).nii.gz- Compressed NIfTI.zarr- Zarr format directories (for large multi-dimensional arrays).tif/.tiff- TIFF image format
Prerequisites
Before uploading, ensure you have:
- Installed and configured the BrainMaps CLI
- Configured S3 storage credentials
- Authenticated with
brainmaps login
Uploading a Single File
To upload a single file:
brainmaps upload file /path/to/brain_scan.tiffWith Additional Options
brainmaps upload file /path/to/brain_scan.nii.gz \
--species 5 \ # Specify species ID
--color "#3366FF" \ # Set visualization color
--verbose # Show detailed outputThe response will include:
- Upload ID
- Status (should be “completed”)
- File size
- S3 URL
Uploading a ZARR Directory
For Zarr format data (which is directory-based):
brainmaps upload folder /path/to/zarr_directory \
--species 3 \
--color "#FF5733"This will upload the entire directory structure to S3 and register it with the API.
Creating a Brain Entry from Uploads
After uploading files, you’ll typically want to create a Brain entry:
# 1. Find the appropriate species
brainmaps species search "octopus"
# 2. Create a brain entry with the uploaded file
brainmaps brain create \
--name "Octopus Brain Sample 123" \
--category "cephalopods" \
--species "octopus vulgaris" \
--file /path/to/brain_scan.tiff \
--color "#3366FF" \
--verboseThe Brain entry will be linked to the uploaded file.
Managing Uploads
List Recent Uploads
brainmaps upload list
# Or specify a limit
brainmaps upload list --limit 20Get Detailed File Information
brainmaps file get <file-id>This returns detailed information about the file, including:
- Upload date
- Size
- Status
- Associated brain (if any)
- S3 URL
Advanced Upload Scenarios
Large File Handling
For large files (>1GB), the CLI shows a progress bar by default:
brainmaps upload file /path/to/large_volume.nii.gzThe progress bar displays:
- Upload speed
- Estimated time remaining
- Percentage complete
Uploading Multiple Files
You can use shell scripts to batch upload multiple files:
#!/bin/bash
for file in *.tiff; do
echo "Uploading $file..."
brainmaps upload file "$file" --species 7
doneTroubleshooting Uploads
Invalid File Type
If you see an error about invalid file types:
Error: Invalid file type. Supported types: .nii, .nii.gz, .zarr, .tif, .tiffEnsure your file has one of the supported extensions and is actually in that format.
S3 Upload Errors
For S3 configuration issues:
Error: AWS credentials not found or invalidVerify your S3 configuration:
brainmaps s3 showAnd reconfigure if needed:
brainmaps s3 configure \
--bucket your-bucket \
--region your-region \
--access-key-id your-key \
--secret-access-key your-secretNetwork Issues
For network connectivity problems:
Error: Connection error: Connection refusedCheck your network connection and the API URL:
brainmaps config get-api-urlBest Practices
- Organize files by species for easier batch uploading
- Use descriptive filenames to identify scan content
- Check species IDs before upload to ensure correct association
- Verify successful uploads with
brainmaps upload list - Use scripts for batch processing of multiple files
- Set appropriate metadata like species and color during upload
Example: Complete Upload Workflow
# 1. Login
brainmaps login
# 2. Search for the correct species
brainmaps species search "human"
# Note the species ID from the results
# 3. Upload the brain scan
brainmaps upload file human_brain_frontal.tiff --species 1 --color "#3366FF" --verbose
# 4. Verify the upload
brainmaps upload list
# 5. Create a brain entry with the uploaded file
brainmaps brain create \
--name "Human Brain Frontal Section" \
--category "human" \
--species "homo sapiens" \
--file human_brain_frontal.tiff \
--color "#3366FF"
# 6. View the brain entry
brainmaps brain list