Skip to content
Davide Punzo edited this page Apr 5, 2017 · 239 revisions

Welcome to the SlicerAstro wiki!


Objective: general description

* [x] Proper visualization of astronomical data cubes: using data astronomical data formats, such as FITS, and astronomical world coordinates system (WCS); * [ ] Quantification: visualization of the beam, generation of Histogram, flux density profiles, moment maps and position-velocity diagrams, statistics linked with the 3-D view, masking volumes with segmentations; * [x] Enabling interactive smoothing in all three dimensions; * [x] Interactive HI data modeling coupled to visualization; * [ ] Introduction of the SAMP protocol to enable interoperability with Topcat, and other VO tools and catalogs.

Additional Users documentation (first-time users are advised to check it): https://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/SlicerAstro

Developers documentation: coming soon...

Check also:

https://arxiv.org/abs/1505.06976

https://arxiv.org/abs/1609.03782

SlicerAstro is a work in progress project. Below you can find a detailed list of the current status. Please, report any bug and error that you may encounter (https://github.com/Punzo/SlicerAstro/issues).

Progress (1):

* [x] FITS reader and AstroVolume done; * [x] WCS included in AstroVolume; * [x] Added AstroLabelMapVolume (WCS compatible); * [x] Generalization of qSlicerUnits; * [x] Slicer dataProbe moduile overrided with AstroDataProbe one; * [x] First desing of the AstroVolume interface done; * [x] Added WCS axis in the 2-D views; * [x] Customization of 2-D and 3-D Views; * [x] Welcoming to SlicerAstro and AstroSampleData modules implemented; * [x] Done!

Progress (2):

* [ ] Beam; * [ ] Histogram; * [ ] flux density profiles; * [ ] easy creation of contour plots; * [ ] moment maps; * [ ] position-velocity diagrams and linking with the projected model rotation curve; * [ ] statistics; * [ ] module for cropping / masking volumes with segmentations (taking care of WCS);

Progress (3):

* [x] module created; * [x] interface designed; * [x] Logic methods implemented on CPU (OpenMP); * [x] Logic methods implemented on GPU (OpenGL); * [x] Done!

Progress (4):

* [x] implementing CloudLasso (3-D Lasso) effect in the segmentation editor; * [x] implementing interface for easy conversion of AstroLabelMapVolume to/from SegmentationNode; * [x] adding tilted-ring model routine (3DBarolo); * [x] Done!

Progress (5):

* [ ] implementing SAMP protocol in SlicerAstro; * [ ] skill to overlay observations at different wavelength (i.e. different WCS and gridding);

General NOTE

* at the moment datacubes NAXIS>3 not supported (NAXIS=4 and NAXIS4=1 -> NAXIS=3). * In Slicer is possible to overley two datacube in the 2-D Views. However, at the moment, SlicerAstro does not perform any regridding and/or reprojection operations. This means that, at the moment, the user should take care to load datacubes with same gridding and and same WCS if she/he desires to overlay them on the 2-D Views. * at the moment the SlicerAstro is not aware of the CELLSCAL keyword. * 3-DSlicer, at the moment, uses Qt4.8.5. For example, using last versions of Ubuntu, it may happen to spot odd behaviour for the popup menus. This will be solved by the upgrade of 3-DSlicer to Qt5 (see https://www.slicer.org/slicerWiki/index.php/Documentation/Labs/Qt5). * OpenGL filters in the current binaries are disabled. They require Slicer_VTK_RENDERING_BACKEND set to OpenGL2 (current 3-DSlicer binaries use OpenGL; https://www.slicer.org/wiki/Documentation/Labs/VTK7). If such features is required the user may try to compile 3-DSlicer following https://www.slicer.org/wiki/Documentation/Nightly/Developers/Build_Instructions and setting in cmake Slicer_VTK_RENDERING_BACKEND=OpenGL2.

Get SlicerAstro

SlicerAstro is an official 3-DSlicer extension. Please, download 3-DSlicer nightly build:

http://download.slicer.org/

donwload SlicerAstro using the 3-DSlicer extension manager tool (available for Linux and MAC): http://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/SlicerApplication/ExtensionsManager

After the installation, please configure the settings (not necessary, but suggested) with the following instructions (to open the setting interface, you may press ctrl+2 / Command ⌘+2):

  • Volume Rendering: setup if the default rendering pipeline runs on CPU or GPU (and the amount of your DRAM).
  • Modules: A) toggle Skip loading of any for the command-line plugins; B) restart; C) Remove all the remaining medical modules by untoggling all the modules which are not included in the following list: Annotations, AstroDataProbe, AstroDataSample, AstroVolume, Cameras, Colors, Data, DataProbe, DataStore, Markups, Reformat, Scene Views, Screen Capture, Segment Editor, Segmentations, Smooth Volume, Subject Hierarchy, Tables, Transforms, Units, Volume Rendering, Volumes, Welcome to Slicer, Welcome to SlicerAstro, Smooth Volume.
  • Set the default startup module: Welcome to SlicerAstro.
  • Set as favourite modules the Astro ones.
  • Restart

For general information about 3-DSlicer and tutorials we refer to

The interface

For information about the GUI and the navigation, we refer to the Slicer documentation:

Markups and crosshair are also very useful tools. Please, check the following links:

Welcome module

The SlicerAstro's Modules Interface

Check https://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/SlicerAstro

Python interactor

It is a very useful util to access run-time the Slicer classes (e.g. the data of the fits file are stored in the AstroVolume class). Python script can also be runned typing on termianl Slicer --python ...

See:

3DSlicer Python scripts repository

SlicerAstro Python scripts repository

  • SmoothRenderSaveVideos.py:
slicer.util.loadVolume("/full_path/galaxy.fits",{"center":True})
mw = slicer.util.mainWindow()
ms = mw.moduleSelector()
# Smooth the datacube
ms.selectModule('AstroSmoothing')
smowidget = slicer.modules.astrosmoothing.widgetRepresentation()
smomrmlpara = smowidget.mrmlAstroSmoothingParametersNode()
smomrmlpara.SetMode("Manual")
# only if a GPU is present:
#smomrmlpara.SetHardware(1)
smowidget.onApply()
ms.selectModule('AstroVolume')
# Setting maximum quality for the rendering
astrovolumewidget = slicer.modules.astrovolume.widgetRepresentation()
astrovolumewidget.onCurrentQualityControlChanged(1)
volumes = slicer.mrmlScene.GetNodesByClass("vtkMRMLAstroVolumeNode")
volumefiltered = volumes.GetItemAsObject(1)
smomrmlpara.SetInputVolumeNodeID(volumefiltered.GetID())
astrovolumewidget.onCurrentQualityControlChanged(1)
# Create videos 
ms.selectModule('ScreenCapture')
screencapturewidget = slicer.modules.screencapture.widgetRepresentation()
instance = screencapturewidget.self()
viewNode = slicer.util.getNode('vtkMRMLViewNode1')
instance.viewNodeSelector.setCurrentNode(viewNode)
instance.numberOfStepsSliderWidget.setValue(360)
instance.videoExportCheckBox.setChecked(1)
instance.videoFormatWidget.setCurrentIndex(1)
instance.videoFileNameWidget.setText("WEIN069.mp4")
instance.videoLengthSliderWidget.setValue(6)
instance.onCaptureButton()
viewNode = slicer.util.getNode('vtkMRMLViewNode2')
instance.viewNodeSelector.setCurrentNode(viewNode)
instance.viewNodeSelector.setCurrentNode(viewNode)
instance.numberOfStepsSliderWidget.setValue(360)
instance.videoExportCheckBox.setChecked(1)
instance.videoFormatWidget.setCurrentIndex(1)
instance.videoFileNameWidget.setText("WEIN069_smoothed.mp4")
instance.videoLengthSliderWidget.setValue(6)
instance.onCaptureButton()
  • Create(alike)MomentMap.py:
# Get the data-cube volume
volumeNode = getNode('name of the object')
datacube = volumeNode.GetImageData()

# Get dimensions
N1 = int(volumeNode.GetAttribute("SlicerAstro.NAXIS1"))
N2 = int(volumeNode.GetAttribute("SlicerAstro.NAXIS2"))
RMS = float(volumeNode.GetAttribute("SlicerAstro.RMS"))

# Create an empty 2-D image
imageSize = [N1, N2, 1]
imageSpacing = [1.0, 1.0, 1.0]
voxelType = vtk.VTK_FLOAT
imageDataTemp = vtk.vtkImageData()
imageDataTemp.SetDimensions(imageSize)
imageDataTemp.AllocateScalars(voxelType, 1)

extentTemp = imageDataTemp.GetExtent()
for i in xrange(extentTemp[0], extentTemp[1]+1):
    for j in xrange(extentTemp[2], extentTemp[3]+1):
       for k in xrange(extentTemp[4], extentTemp[5]+1):
          imageDataTemp.SetScalarComponentFromFloat(i,j,k,0,0.)

# calculate moment map
imageData = volumeNode.GetImageData()
extent = imageData.GetExtent()
for i in xrange(extent[0], extent[1]+1):
    for j in xrange(extent[2], extent[3]+1):
       sum = 0.
       for k in xrange(extent[4], extent[5]+1):
          value = imageData.GetScalarComponentAsFloat(i,j,k,0)
          if value > 3 * RMS:
             sum += imageData.GetScalarComponentAsFloat(i,j,k,0)
       imageDataTemp.SetScalarComponentFromFloat(i,j,0,0,sum)

imageDataTemp.Modified()
point = imageDataTemp.GetPointData()
array = piont.GetArray("ImageScalars")
point.Modified()
array.Modified()
array.GetValueRange()

# create Astro Volume for the moment map
astroVolumeLogic = slicer.modules.astrovolume.logic()
volumeNodeMomentMap = astroVolumeLogic.CloneVolume(slicer.mrmlScene, volumeNode, 'MomentMap')

# modify fits attributes
volumeNodeMomentMap.SetAttribute("SlicerAstro.NAXIS", "2")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.NAXIS3")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.CROTA3")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.CRPIX3")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.CRVAL3")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.CTYPE3")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.CUNIT3")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.DTYPE3")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.DRVAL3")
volumeNodeMomentMap.RemoveAttribute("SlicerAstro.DUNIT3")

# copy 2-D image into the Astro Volume object
volumeNodeMomentMap.SetAndObserveImageData(imageDataTemp)
volumeNodeMomentMap.UpdateNoiseAttributes()
volumeNodeMomentMap.UpdateRangeAttributes()

# change colorMap of the 2-D image
displayNode = volumeNodeMomentMap.GetDisplayNode()
displayNode.SetAndObserveColorNodeID('vtkMRMLColorTableNodeRainbow')

# changing the colorMap parameters
#displayNode.AutoWindowLevelOff()
#displayNode.SetWindow(??)
#displayNode.SetLevel(??)


run as: ./Slicer --python-script SmoothRenderSaveVideos.py or copy and paste in the python console

more to come...

Clone this wiki locally