Skip to content

Commit

Permalink
Merge pull request #252 from arnaudbore/master
Browse files Browse the repository at this point in the history
Update methodology + documentation
  • Loading branch information
cbedetti authored Sep 15, 2016
2 parents e42227c + f81c5a7 commit 0f7ce4c
Show file tree
Hide file tree
Showing 35 changed files with 701 additions and 144 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
__pycache__/
*.py[cod]
*$py.class
*~
10 changes: 5 additions & 5 deletions core/toad/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ def __getConfigFiles(self, arguments):

#config file could be found into the root of the project, into the subject and into the backup directory
if arguments.subject:

configFile = "{}/configRunning.cfg".format(os.path.join(arguments.subject, "00-backup"))
if os.path.exists(configFile):
configFiles.append(configFile)

for directory in [os.path.dirname(arguments.subject),
arguments.subject,
os.path.join(arguments.subject, "00-backup")]:
configFile = "{}/config.cfg".format(directory)
if os.path.exists(configFile):
configFiles.append(configFile)

# Add configRunning file because every tasks
configFile = "{}/configRunning.cfg".format(os.path.join(arguments.subject, "00-backup"))
if os.path.exists(configFile):
configFiles.append(configFile)

if arguments.config:
for config in arguments.config:
if os.path.isfile(config):
Expand Down
198 changes: 195 additions & 3 deletions core/toad/qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def createTaskHtml(self, tags, htmlLink=None):
"""
versions = ''
if self.getName() == 'qa':
print self.logDir
print self.get('general','versions_file_name')
versions = minidom.parse(os.path.join(
self.logDir, self.get('general','versions_file_name')))
versions = versions.toprettyxml()
Expand Down Expand Up @@ -240,10 +242,30 @@ def createMethoHtml(self):
jinja2Env = Environment(
loader=FileSystemLoader(templateDir), trim_blocks=True)
tpl = jinja2Env.get_template('metho.tpl')
tags_metho = self.__getTags()

tags_softwares = self.__getVersions()
tags_metho = self.__getTags(tags_softwares)
# print tags_metho
htmlCode = tpl.render(**tags_metho)
util.createScript(os.path.join(self.qaDir,'metho.html'), htmlCode)

def __getVersions(self):
tags = {}
versions = minidom.parse(os.path.join(
self.logDir, self.get('general','versions_file_name')))
softs = versions.getElementsByTagName('softwares')[-1].getElementsByTagName('software')

for soft in softs:
currentVersion = str(soft.getElementsByTagName('version')[0].firstChild.data)
currentSoft = str(soft.getElementsByTagName('name')[0].firstChild.data).lower()

if 'freesurfer' in currentSoft:
currentVersion = currentVersion.split('pub-')[1]

tags[ currentSoft + '_vers'] = currentVersion


return tags

def configGet(self, section, key):
try:
Expand Down Expand Up @@ -285,7 +307,8 @@ def configFillSection(self, section, withName = False):

return tags

def __getTags(self):
def __getTags(self, tags_softwares):


methodology = self.configFillSection('methodology') # Fill tags with config file informations
denoising = self.configFillSection('denoising', True)
Expand All @@ -297,15 +320,184 @@ def __getTags(self):
hardimrtrix = self.configFillSection('hardimrtrix', True)
hardidipy = self.configFillSection('hardidipy', True)
tractographymrtrix = self.configFillSection('tractographymrtrix', True)
tractquerier = self.configFillSection('tractquerier', True)
tractfiltering = self.configFillSection('tractfiltering', True)
tractometry = self.configFillSection('tractometry', True)

references = self.configFillSection('references')

tags = util.merge_dicts(methodology, denoising, denoising, correction, upsampling,
tensorfsl, tensordipy, tensormrtrix, hardimrtrix, hardidipy, tractographymrtrix)
tensorfsl, tensordipy, tensormrtrix, hardimrtrix, hardidipy, tractographymrtrix, tractquerier, tractfiltering, tractometry, tags_softwares)

# Special case for 3T Tim Trio
if tags['magneticfieldstrength'] == '3' and tags['mrmodel'] == 'TrioTim' and tags['denoising_number_array_coil'] == '4':
tags['number_array_coil'] = 12
else:
tags['number_array_coil'] = tags['denoising_number_array_coil']

methodology = ''
bibReferences = []

indexReferences = 1
if not tags['denoising_ignore']:
methodology += 'First, DWI were denoised using {} method [{}]. '.format(tags['denoising_algorithm'],indexReferences)
if tags['denoising_algorithm'] == 'nlmeans':
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_nlmeans']))
elif tags['denoising_algorithm'] == 'aonlm':
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_aonlm']))
elif tags['denoising_algorithm'] == 'lpca':
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_lpca']))
indexReferences += 1

if not tags['correction_ignore']:
if not tags['denoising_ignore']:
methodology += 'Then, they were corrected using {} [{}]. '.format(tags['correction_method'],indexReferences)
methodology += 'Gradient directions were corrected corresponding to motion correction parameters. '
else:
methodology += 'First, DWI were corrected using {} [{}]. '.format(tags['correction_method'],indexReferences)

methodology += 'Motion-corrected images '

bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_correction']))
indexReferences += 1


else:
methodology += 'DWI '

methodology += 'were upsampled using {} interpolation (upsampling to anatomical resolution). '.format(tags['upsampling_interp'])

methodology += '</ br>Anatomical image went through Freesurfer pipeline [{}] in order to be used in the Anatomically-Constrained Tractography (ACT). T1 image was registered to the DWI '.format(indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_freesurfer']))
indexReferences += 1

if not (tags['tensorfsl_ignore'] and tags['tensordipy_ignore'] and tags['tensormrtrix_ignore']):
methodology += '<p>Eigenvectors, eigenvalues, fractional anisotropy (FA), radial diffusivity (RD), axial diffusivity (AD) and mean diffusivity (MD) were extracted from tensor reconstruction using '
if not (tags['tensorfsl_ignore'] and tags['tensordipy_ignore'] and tags['tensormrtrix_ignore']):
methodology += 'FDT toolbox from FSL {} using {} method [{}] '.format(tags['fsl_vers'], tags['tensorfsl_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tensorfsl']))
indexReferences += 1

methodology += 'and DIPY {} using {} method [{}] '.format(tags['dipy_vers'], tags['tensordipy_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_dipy']))
indexReferences += 1

methodology += 'and MRtrix {} using {} method [{}]. '.format(tags['mrtrix_vers'], tags['tensormrtrix_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tensormrtrix']))
indexReferences += 1

elif not (tags['tensorfsl_ignore'] and tags['tensordipy_ignore']):
methodology += 'FDT toolbox from FSL {} using {} method [{}] '.format(tags['fsl_vers'], tags['tensorfsl_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tensorfsl']))
indexReferences += 1

methodology += 'and DIPY {} using {} method [{}]. '.format(tags['dipy_vers'], tags['tensordipy_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_dipy']))
indexReferences += 1

elif not (tags['tensorfsl_ignore'] and tags['tensormrtrix_ignore']):
methodology += 'FDT toolbox from FSL {} using {} method [{}] '.format(tags['fsl_vers'], tags['tensorfsl_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tensorfsl']))
indexReferences += 1

methodology += 'and MRtrix {} using {} method [{}]. '.format(tags['mrtrix_vers'], tags['tensormrtrix_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tensormrtrix']))
indexReferences += 1

elif not (tags['tensordipy_ignore'] and tags['tensormrtrix_ignore']):
methodology += 'DIPY {} using {} method [{}]. '.format(tags['dipy_vers'], tags['tensordipy_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_dipy']))
indexReferences += 1

methodology += 'and MRtrix {} using {} method {}]. '.format(tags['mrtrix_vers'], tags['tensormrtrix_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tensormrtrix']))
indexReferences += 1

elif not tags['tensorfsl_ignore']:
methodology += 'FDT toolbox from FSL {} using {} method [{}]. '.format(tags['fsl_vers'], tags['tensorfsl_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tensorfsl']))
indexReferences += 1

elif not tags['tensordipy_ignore']:
methodology += 'DIPY {} using {} method [{}]. '.format(tags['dipy_vers'], tags['tensordipy_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_dipy']))
indexReferences += 1

elif not tags['tensormrtrix_ignore']:
methodology += 'MRtrix {} using {} method [{}]. '.format(tags['mrtrix_vers'], tags['tensormrtrix_fitmethod'], indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tensormrtrix']))
indexReferences += 1

methodology += '</p>'

if not (tags['hardidipy_ignore'] or tags['hardimrtrix_ignore']):
methodology += '<p>Fiber orientation distribution function (fODF) reconstruction was done using '

if not tags['hardidipy_ignore']:
methodology += 'DIPY'
if tags['tensordipy_ignore']:
methodology += ' {} [{}]'.format(tags['ref_dipy'], indexReferences)

elif not tags['hardimrtrix_ignore']:
methodology += 'MRtrix'
if tags['tensordipy_ignore']:
methodology += ' {} [{}]'.format(tags['ref_mrtrix'], indexReferences)

if not (tags['hardimrtrix_ignore'] and tags['hardidipy_ignore']):
methodology += ' and MRtrix. '
else:
methodology += '. '

if not tags['hardidipy_ignore']:
methodology += 'Dipy method: The response function for a single fibre population was estimated using {}. '.format(tags['hardidipy_algorithmresponsefunction'])

methodology += 'This response function was then used to estimate the FOD for each voxel using Constrained Spherical Deconvolution (CSD) [{}] with a maximum spherical harmonic order lmax of {}. '.format(indexReferences, tags['hardidipy_lmax'])
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_hardimrtrix']))
indexReferences += 1

if not tags['hardimrtrix_ignore']:
methodology += 'MRtrix method: The response function for a single fibre population was estimated using {} algorithm [{}]. '.format(tags['hardimrtrix_algorithmresponsefunction'], indexReferences)
if tags['hardidipy_algorithmresponsefunction'] == 'tournier':
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_estimationResponseTournier']))
indexReferences += 1
if tags['hardidipy_ignore']:
methodology += 'This response function was then used to estimate the FOD for each voxel using Constrained Spherical Deconvolution (CSD) [{}] with a maximum spherical harmonic order lmax of {}. '.format(indexReferences, tags['hardimrtrix_lmax'])

bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_hardimrtrix']))
indexReferences += 1
else:
methodology += 'This response function was then used to estimate the FOD for each voxel using Constrained Spherical Deconvolution (CSD) [{}] with a maximum spherical harmonic order lmax of {}. '.format(indexReferences-1, tags['hardimrtrix_lmax'])

if not (tags['hardidipy_ignore'] or tags['hardimrtrix_ignore']):
methodology += '</p>'

if not tags['tractographymrtrix_ignore']:
methodology += '<p>{} tractography was performed using ACT [{}] algorithm. Tractogram of {} streamlines was generated. Any track with length > {} mm was discarded. Because of storage restriction we had to downsample streamlines to a factor of {}. '.format(tags['tractographymrtrix_algorithm'], indexReferences, tags['tractographymrtrix_numbertracks'], tags['tractographymrtrix_maxlength'], tags['tractographymrtrix_downsample'])

bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tractomrtrix']))
indexReferences += 1

if not tags['tractquerier_ignore']:
methodology += 'Then, we used White Matter Query Language [{}] to select bundles of interest. '.format(indexReferences)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tractquerier']))
indexReferences += 1

if not tags['tractfiltering_ignore']:
methodology += 'These bundles have been filtered to remove outliers streamlines [{}]. '.format(indexReferences)

if not tags['tractometry_ignore']:
methodology += '<p>Finally, we use metrics from reconstruction method (HARDI and Tensor) to get these metrics along the streamlines.'.format(indexReferences-1)
bibReferences.append("<p>[%s] %s</p></ br>" % (indexReferences, references['ref_tractometry']))
indexReferences += 1


tags['methodology'] = methodology

allRefs = ''
for ref in bibReferences:
allRefs = allRefs + '\n' + ref

tags['allReferences'] = allRefs

return tags

4 changes: 2 additions & 2 deletions doc/toad/mkdocs_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ site_dir: html/en
theme_dir: custom_theme
use_directory_urls: false
site_favicon: figs/toad.ico
copyright: © TOAD 2015
copyright: © TOAD 2016
pages:
- Home: 'index.md'
- Tutorial:
Expand All @@ -20,7 +20,7 @@ pages:
- Tasks:
- 'Tasks overview': 'tasks/overview.md'
- '00-Backup': 'tasks/00-Backup.md'
- '00-Outputs': 'tasks/18-Outputs.md'
- '00-Outputs': 'tasks/00-Outputs.md'
- '00-Signal-noise ratio': 'tasks/00-Snr.md'
- '00-QA': 'tasks/00-Qa.md'
- '01-Preparation': 'tasks/01-Preparation.md'
Expand Down
2 changes: 1 addition & 1 deletion doc/toad/mkdocs_fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pages:
- 'Vue d’ensemble': 'tasks/overview.md'
- '00-Backup': 'tasks/00-Backup.md'
- '00-QA': 'tasks/00-Qa.md'
- '00-Outputs': 'tasks/18-Outputs.md'
- '00-Outputs': 'tasks/00-Outputs.md'
- '00-Ratio signal sur bruit': 'tasks/00-Snr.md'
- '01-Preparation': 'tasks/01-Preparation.md'
- '02-Parcellation': 'tasks/02-Parcellation.md'
Expand Down
10 changes: 5 additions & 5 deletions doc/toad/src/en/about/license.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# User agreement

If you use TOAD, you must agree to the following:
Upon downloading and using TOAD, you are agreeing to the following:

- ensure to use the latest stable version of TOAD (check the website)
- cite TOAD [FIXME] in your publications
- Ensure the use of the latest stable version of TOAD (check the website)
- Cite TOAD [FIXME] and articles in the QA in your publications


# Code license

The source code of TOAD is freely available on [Github](https://github.com/UNFmontreal/toad) under the GPL v2 license.

TOAD is a pipeline to automatically preprocess diffusion imaging data (DWI/DTI).
TOAD is an automated pipeline to preprocess diffusion imaging data (DWI/DTI).
Copyright (C) 2015, TOAD

This program is free software; you can redistribute it and/or
This program is a free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2.

Expand Down
Binary file added doc/toad/src/en/figs/KAurousseau.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/toad/src/en/figs/diagram_tasks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0f7ce4c

Please sign in to comment.