Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
128 lines (103 sloc) 3.82 KB
import os
import string
import textwrap
import unittest
import vtk, qt, ctk, slicer
from slicer.ScriptedLoadableModule import *
import logging
# DMRIInstall
class DMRIInstall(ScriptedLoadableModule):
helpText = textwrap.dedent(
The SlicerDMRI extension provides diffusion-related tools including:
<li> Diffusion Tensor Estimation</li>
<li>Tractography Display</li>
<li>Tractography Seeding</li>
<li>Fiber Tract Measurement</li>
For more information, please visit:
&nbsp;&nbsp; <a href=""></a>
Questions are welcome on the Slicer forum:
&nbsp;&nbsp; <a href=""></a><br><br>
errorText = textwrap.dedent(
<h5 style="color:red">The SlicerDMRI extension is currently unavailable.</h5><br>
Please try a manual installation via the Extension Manager,
and contact the Slicer forum at:<br><br>
&nbsp;&nbsp;<a href=""></a><br><br>
With the following information:<br>
Slicer version: {builddate}<br>
Slicer revision: {revision}<br>
Platform: {platform}
revision =,
platform =
def __init__(self, parent):
# Hide this module if SlicerDMRI is already installed
model =
if model.isExtensionInstalled("SlicerDMRI"):
parent.hidden = True
ScriptedLoadableModule.__init__(self, parent)
self.parent.categories = ["Diffusion"]
self.parent.title = "Install Slicer Diffusion Tools (SlicerDMRI)"
self.parent.dependencies = []
self.parent.contributors = ["Isaiah Norton (BWH), Lauren O'Donnell (BWH)"]
self.parent.helpText = DMRIInstall.helpText
self.parent.helpText += self.getDefaultModuleDocumentationLink()
self.parent.acknowledgementText = textwrap.dedent(
SlicerDMRI supported by NIH NCI ITCR U01CA199459 (Open Source Diffusion MRI
Technology For Brain Cancer Research), and made possible by NA-MIC, NAC,
BIRN, NCIGT, and the Slicer Community.
class DMRIInstallWidget(ScriptedLoadableModuleWidget):
"""Uses ScriptedLoadableModuleWidget base class, available at:
def setup(self):
self.textBox = ctk.ctkFittedTextBrowser()
self.textBox.setOpenExternalLinks(True) # Open links in default browser
# Apply Button
self.applyButton = qt.QPushButton("Install SlicerDMRI")
self.applyButton.toolTip = 'Installs the "SlicerDMRI" extension from the Diffusion category.'
self.applyButton.icon = qt.QIcon(":/Icons/ExtensionDefaultIcon.png")
self.applyButton.enabled = True
self.applyButton.connect('clicked()', self.onApply)
def onError(self):
self.applyButton.enabled = False
def onApply(self):
emm =
if emm.isExtensionInstalled("SlicerDMRI"):
self.textBox.setHtml("<h4>SlicerDMRI is already installed.<h4>")
self.applyButton.enabled = False
md = emm.retrieveExtensionMetadataByName("SlicerDMRI")
if not md or 'extension_id' not in md:
return self.onError()
if emm.downloadAndInstallExtension(md['extension_id']):"Restart to complete SlicerDMRI installation?")
You can’t perform that action at this time.