# Immunotherapy related adverse effects toolbox

Manage images and data related to irAE project.

# Slicer module
A Slicer module was created to assist Radiology and Nuclear Medicine phsicians in
reviewing the images. The following lists the installation, setup and usage of the module.

## Installation

Here is the installation [video][iraeMMInstallation] that shows required steps.

Download the [code][iraemm] and [dependencies][SlicerLabkeyExtension]. Unzip. To
have Slicer know where the files are, open Slicer, and under Edit->Application settings 
select Modules section. Under Paths, click on Add and navigate to newly unzipped
directories. We need `labkeyBrowser` and `DICOMtools` from `SlcierLabkeyExtension` and 
`slicerModule` from `iraeMM` code. After clicking `OK`, Slicer will and has to
be restarted.

## Setup
To access LabKey, the Slicer tools must be configured. Do that by selecting LabKey->labkeyBrowser
module from module list and fill appropriate fields.

### Onko-nix
For accessing OIL internal site, the settings are:
- Server: `http://onko-nix.onko-i.si:8080
- Labkey username: username, given at the LabKey site, typically your email
- Labkey password: password, generated when accessing LabKey site

The rest needn't be changed. 

### Setup verification and storage
Once the data is entered, click on Init to check whether LabKey can be accessed. If
the button turns green, you are OK. Do `Save configuration`. 

## Usage


See [video][iraeMMWorkflow] of module use, illustrating steps below. 
Old version [here][iraeMMWorkflowOld].

Use Labkey->iraemmBrowser module. The `Patients` section lets you select the patient
and corresponding visit. On `Load` the data gets loaded from the server. 

### Converting segmentations
The segmentations on server are stored as label maps, which have to be 
converted to segments for Slicer. To do that, select `Segmentations` module 
from the drop-down menu. Under Active segmentations, a new segmentation must
be created by selecting `Create new segmentation` option from the pull down menu. Scroll down 
to `Export/import models and labelmaps` and change the mode to `Import` by 
moving the radio button selection. The Input type should be set to `labelmap`. Input
node should match selected patient/visit pair and should end in `Segm`. Click on `Import` 
button further down. 

### Removing labelmap volume
The source labelmap volume will obscure other volumes, so we should delete it. Do that
by selecting `Volumes` module and rotating˛`Active volume` to point to labelmap
used in segmentation creation. Once selected, select `Delete current volume` from
the same pull down menu next to Active volume.

### Viewing segmentations
Labelmap was converted to a set of Segments, which are listed in the `Segmentations` 
module. By clicking on the open/closed eye icon, a segment can be made visible or invisible
on the windows. Further setup can be made in the `View controls` module, where
visibility and mode of each volume can be adjusted. For the segmentations, which
appear in the top layer, either continuous, continuous with sharpened edges or edge 
only mode are available by clicking on display icon.

## Entering review
The module has a review section. Select LabKey->iraemmBrowser and navigate to review
secion. Four levels of agreement can be selected and an addition Comments field is 
available. Once filled, review is submitted by clicking on Submit button. Choices can be
changed any time and new values can be pushed to database with further clicks of
the button. 

## Clearing
Once done, a patient should be cleared to minimize interference in segmentation 
evaluation. Do that by pressing `Clear` in `Patients` section of the `iraeMMBrowser` module. 


### Dependencies 
To access LabKey, the [python API][labkeyInterface] was used.
Anonymization and NIfTI conversion are based on phenomenal [nibabel][] tools. 
Data storage is provided by [Orthanc][] with associated [interface][orthancInterface].

### Usage

Anonymization must be run as a `tomcat8` user for access to data files. Check setup 
in the `anonymization.py` and run it with `runPython.sh anonymization.py`. 

[SlicerLabkeyExtension]:http://wiscigt.powertheword.com/labkey/SlicerLabkeyExtension/-/archive/SlicerExtensionIndex/SlicerLabkeyExtension-SlicerExtensionIndex.zip
[iraemm]: http://wiscigt.powertheword.com/oil/iraemm/-/archive/master/iraemm-master.zip
[nibabel]: https://nipy.org/nibabel/gettingstarted.html
[labkeyInterface]: http://wiscigt.powertheword.com/andrej.studen/labkeyInterface
[Orthanc]:https://www.orthanc-server.com
[orthancInterface]: http://wiscigt.powertheword.com/andrej.studen/orthancinterface
[iraeMMWorkflowOld]: https://med1.fmf.uni-lj.si/owncloud/index.php/s/wrKOo1iUzgePzTi
[iraeMMWorkflow]: https://med1.fmf.uni-lj.si/owncloud/index.php/s/iEETqswhTjlI2hV
[iraeMMInstallation]: https://med1.fmf.uni-lj.si/owncloud/index.php/s/pAe4NBONHOGgEYO