Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dwi preprocessing using metadata #15

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

yeunkim
Copy link

@yeunkim yeunkim commented Apr 25, 2017

Diffusion pre-processing using metadata from sidecar files.

@chrisgorgo
Copy link
Contributor

Does this one replace #13?

@yeunkim
Copy link
Author

yeunkim commented Apr 25, 2017

Yes.

Copy link
Contributor

@chrisgorgo chrisgorgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, but the code for finding bvecs seem overly complex. Hopefully after this will get implemented: bids-standard/pybids#9 things can be cleaned up (in another PR).

Dockerfile Outdated
@@ -52,10 +52,10 @@ ENV PATH /opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:
# Install FSL 5.0.9
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
curl -sSL http://neuro.debian.net/lists/trusty.us-ca.full >> /etc/apt/sources.list.d/neurodebian.sources.list && \
curl -sSL http://neuro.debian.net/lists/xenial.us-ca.full >> /etc/apt/sources.list.d/neurodebian.sources.list && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you need to change the base Ubuntu distribution?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I actually wasn't aware of this change. There wasn't any need - sorry about that.

run.py Outdated
@@ -193,7 +194,7 @@ def run_diffusion_processsing(**args):
'fMRISurface', 'DiffusionPreprocessing'],
default=['PreFreeSurfer', 'FreeSurfer', 'PostFreeSurfer',
'fMRIVolume', 'fMRISurface',
'DiffusionPreprocessing'])
'DiffusionPreprocessing', 'TaskfMRIAnalysis'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from another PR? This one should be just about DWI right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes.

run.py Outdated
assert all(len(dwi_dict[k]) for k,v in dwi_dict.items())

for dirnum in set(dwi_dict['bval']):
idxs = { i for k,v in dwi_dict.iteritems() for i in range(0,len(dwi_dict['bval'])) if v[i] == dirnum }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment explaining what this line does?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 450: I made a mistake - it's supposed to be
assert all(len(dwi_dict[k]) ==n for k,v in dwi_dict.items())

Line 453: extracts the index values in dwi_dict['bval'] if the value matches "dirnum", which is the number of directions (i.e. 98 or 99). These index values gets used to find the PE directions, dwi files names, etc. in the dictionary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could add this comment to the code it would be easier for people in the future to understand this code. Thanks!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course!

run.py Outdated
for stage, stage_func in dwi_stage_dict.iteritems():
if stage in args.stages:
stage_func()
except:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace this with a more specific catch (narrower in the amount of code it encomapses and types of exceptions it is suppose to catch). Right now it will catch all exceptions making debugging really hard.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

run.py Outdated
onerun= True
numruns = {'run-01'}
if numruns:
for session in numruns:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for run in numruns ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run is a function - I believe. Would you like me to rename the variable session?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would make more sense since you are iterating over runs not sessions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could change it to numrun ?

run.py Outdated
@@ -485,6 +491,6 @@ def run_diffusion_processsing(**args):
for stage, stage_func in dwi_stage_dict.iteritems():
if stage in args.stages:
stage_func()
except:
except NameError:
print("You may have missing diffusion data in the positive phase encoding direction.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tra/except statement still encompases a huge chunk of code that could produce "NameError" that does not necessarily mean that there is missing diffusion data in the positive phase encoding direction. This should be made more specific. Furthermore we should exit with a non zero code to indicate that something did not work correctly.

@@ -55,7 +55,7 @@ RUN apt-get update && \
curl -sSL http://neuro.debian.net/lists/trusty.us-ca.full >> /etc/apt/sources.list.d/neurodebian.sources.list && \
apt-key adv --recv-keys --keyserver hkp://pgp.mit.edu:80 0xA5D32F012649A5A9 && \
apt-get update && \
apt-get install -y fsl-core=5.0.9-3~nd14.04+1 && \
apt-get install -y fsl-core=5.0.9-1~nd+1+nd16.04+1 && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are those changes still necessary applicable to this PR? (applies to connectome-workbench as well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants