bids-apps / baracus

Predicts brain age, based on data from Freesurfer 5.3
Apache License 2.0
9 stars 9 forks source link

BIDS validity + Freesurfer operation error. #8

Closed jlhanson5 closed 7 years ago

jlhanson5 commented 7 years ago

Hello folks interested in Baracus,

I'm new to BIDS and using docker, and ran into some issues running the baracus preprocessing. I validated my dataset and BIDS folder structure via http://incf.github.io/bids-validator/, and then ran:

docker run -ti --rm \ -v /home/jamielh/Volumes/Hanson/Pitt_PYS/BIDS_test/sub-10044/:/data/in \ -v /home/jamielh/Volumes/Hanson/Pitt_PYS/BIDS_test/derivatives/sub-10044/baracus:/data/out \ bids/baracus /data/in /data/out participant \ --license_key "XX"

My data is in /home/jamielh/Volumes/Hanson/Pitt_PYS/BIDS_test/sub-10044/ and any derived data will be stored in /home/jamielh/Volumes/Hanson/Pitt_PYS/BIDS_test/derivatives/sub-10044/baracus. I'm just testing things in a folder called BIDS_test (which just contains that one subject, and again (I think) it passed BIDS validation. When I put the above code into my command line, I get the two errors noted below...

jamielh@pfc:~/Volumes/Hanson/Pitt_PYS/BIDS_test$ docker run -ti --rm \

-v /home/jamielh/Volumes/Hanson/Pitt_PYS/BIDS_test/sub-10044/:/data/in \ -v /home/jamielh/Volumes/Hanson/Pitt_PYS/BIDS_test/derivatives/sub-10044/baracus:/data/out \ bids/baracus /data/in /data/out participant \ --license_key "XX" This does not appear to be a BIDS dataset. For more info go to http://bids.neuroimaging.io/

Traceback (most recent call last): File "/usr/local/anaconda/bin/run_brain_age_bids.py", line 6, in exec(compile(open(file).read(), file, 'exec')) File "/code/scripts/run_brain_age_bids.py", line 75, in sessions_to_analyze, args.n_cpus, args.license_key) File "/code/baracus/prepare.py", line 54, in run_prepare_all os.symlink(os.path.join(fsav_dir, fsav), os.path.join(freesurfer_dir, fsav)) OSError: [Errno 95] Operation not supported: '/opt/freesurfer/subjects/fsaverage' -> '/data/out/freesurfer/fsaverage'

One looks to be an error about BIDS... but my data should be validated? And then I get an error about Freesurfer symbolic linkage. My server doesn't support symbolic linkages (but has lots of space, so I could easily copy files instead of linking things). I wondered if folks had run into this, and how best to work around the issues (and/or what I was doing incorrectly). Any thoughts are greatly appreciated!

Thanks, Jamie.

chrisgorgo commented 7 years ago

@fliem will know better, but this seems that an issue with linking of fsaverage that is needed to run FreeSurfer. There is a workaround for this in the freesurfer BIDS app that might need to be ported to baracus to fix this. A fix would involve changing this symlink to a copy https://github.com/BIDS-Apps/baracus/blob/master/baracus/prepare.py#L54.

You can also run BARACUS without the need to install or run docker on the http://OpenNeuro.org platform.

jlhanson5 commented 7 years ago

As an additional follow-up, I pivoted to OpenNeuro (thanks for the suggestion). Things are running now...BUT there may be an issue (in file mode) for BARACUS to find the Liem2016 model files... (see error below)

jamielh@pfc:~/Volumes/Hanson/Pitt_PYS/Pitt_Freesurfer$ ~/Volumes/Hanson/Training_Resources/baracus/build/scripts-3.5/run_brain_age_files.py --participant_label s10044 --models Liem2016__full_2samp_training --lh_thickness_file /home/jamielh/Volumes/Hanson/Pitt_PYS/Pitt_Freesurfer/s10044.lh.thickness.00.mgh --rh_thickness_file /home/jamielh/Volumes/Hanson/Pitt_PYS/Pitt_Freesurfer/s10044.rh.thickness.00.mgh --lh_area_file /home/jamielh/Volumes/Hanson/Pitt_PYS/Pitt_Freesurfer/s10044.lh.area.00.mgh --rh_area_file /home/jamielh/Volumes/Hanson/Pitt_PYS/Pitt_Freesurfer/s10044.rh.area.00.mgh --aseg_file /home/jamielh/Volumes/Hanson/Pitt_PYS/Pitt_Freesurfer/s10044_aseg_stats.txt /home/jamielh/Volumes/Hanson/Pitt_PYS/Pitt_Freesurfer/baracus /home/jamielh/.local/lib/python3.5/site-packages/dicom/init.py:53: UserWarning: This code is using an older version of pydicom, which is no longer maintained as of Jan 2017. You can access the new pydicom features and API by installing pydicom from PyPI. See 'Transitioning to pydicom 1.x' section at pydicom.readthedocs.org for more information.

warnings.warn(msg) Traceback (most recent call last): File "/home/jamielh/Volumes/Hanson/Training_Resources/baracus/baracus/predict.py", line 36, in load_model with open(model_file, 'r') as f: FileNotFoundError: [Errno 2] No such file or directory: '/home/jamielh/Volumes/Hanson/Training_Resources/baracus/models/Liem2016__full_2samp_training/aseg/trained_model.pkl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/jamielh/Volumes/Hanson/Training_Resources/baracus/build/scripts-3.5/run_brain_age_files.py", line 42, in subject_label=subject) File "/home/jamielh/Volumes/Hanson/Training_Resources/baracus/baracus/predict.py", line 107, in predict_brain_age_single_subject fitted_models = get_models(model_dir, model=ba_model) File "/home/jamielh/Volumes/Hanson/Training_Resources/baracus/baracus/predict.py", line 51, in get_models models[m] = load_model(model_file) File "/home/jamielh/Volumes/Hanson/Training_Resources/baracus/baracus/predict.py", line 41, in load_model with open(model_file, 'rb') as f: FileNotFoundError: [Errno 2] No such file or directory: '/home/jamielh/Volumes/Hanson/Training_Resources/baracus/models/Liem2016__full_2samp_training/aseg/trained_model.pkl'

fliem commented 7 years ago

Hi guys,

1.

My data is in /home/jamielh/Volumes/Hanson/Pitt_PYS/BIDS_test/sub-10044/

You'd probably need to remove "sub-10044" from the data path, so that you pass the BIDS root dir, like -v /home/jamielh/Volumes/Hanson/Pitt_PYS/BIDS_test/:/data/in

You can use "--participant_label" to only run one participant

2. Looks like you try to run file mode without docker. I recommend following this example and use docker with file mode as well.

jlhanson5 commented 7 years ago

Great, thanks for that help!

Any way to work around the lack of symbolic linkage on my system? I tried to alias /opt/freesurfer/subjects/fsaverage but my system won't take that as a valid (alias) name.

Traceback (most recent call last): File "/usr/local/anaconda/bin/run_brain_age_bids.py", line 6, in exec(compile(open(file).read(), file, 'exec')) File "/code/scripts/run_brain_age_bids.py", line 75, in sessions_to_analyze, args.n_cpus, args.license_key) File "/code/baracus/prepare.py", line 54, in run_prepare_all os.symlink(os.path.join(fsav_dir, fsav), os.path.join(freesurfer_dir, fsav)) OSError: [Errno 95] Operation not supported: '/opt/freesurfer/subjects/fsaverage' -> '/data/out/freesurfer/fsaverage'

fliem commented 7 years ago

Sorry for the long delay. I am on leave at the moment and will be back in October. Feel free to submit a PR changing the line Chris mentioned. Otherwise a quick workaround would be to start baracus and wait for it to fail, then copy fsaverage from a local freesurfer download into the baracus/freesurfer folder, then start baracus again.

fliem commented 7 years ago

I just released a new version that fixes the symlink issue