From ef27a3d4ccef6e88ee4a1069d9db63104d6ccdb3 Mon Sep 17 00:00:00 2001 From: Peter Neher Date: Thu, 5 Dec 2019 09:59:02 +0100 Subject: [PATCH 1/3] Adjust resource location --- .../src/internal/QmitkTractSegView.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.python/src/internal/QmitkTractSegView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging.python/src/internal/QmitkTractSegView.cpp index f151f8c..44aa39b 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging.python/src/internal/QmitkTractSegView.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging.python/src/internal/QmitkTractSegView.cpp @@ -113,7 +113,7 @@ void QmitkTractSegView::Start() // get python script as string QString data; - QString fileName(":/QmitkDiffusionImaging/tractseg.py"); + QString fileName(":/QmitkDiffusionPython/tractseg.py"); QFile file(fileName); if(!file.open(QIODevice::ReadOnly)) { qDebug()<<"filenot opened"< m_PythonServiceRef = context->GetServiceReference(); mitk::IPythonService* m_PythonService = dynamic_cast ( context->GetService(m_PythonServiceRef) ); From 8ddfcf37696db92caa7f0d6007ae1cecc12914bb Mon Sep 17 00:00:00 2001 From: Peter Neher Date: Thu, 5 Dec 2019 14:19:35 +0100 Subject: [PATCH 2/3] Flipping axes correctly --- .../resources/tractseg.py | 17 +++++++---------- .../src/internal/QmitkTractSegView.cpp | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.python/resources/tractseg.py b/Plugins/org.mitk.gui.qt.diffusionimaging.python/resources/tractseg.py index 8acde17..e2253dd 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging.python/resources/tractseg.py +++ b/Plugins/org.mitk.gui.qt.diffusionimaging.python/resources/tractseg.py @@ -8,11 +8,10 @@ data = sitk.GetArrayFromImage(in_image) data = np.nan_to_num(data) + swapaxes = False - if data.shape != (sx, sy, sz): - print("Swapping axes!") - data = np.swapaxes(data, 0, 2) - swapaxes = True + data = np.swapaxes(data, 0, 2) + swapaxes = True affine = np.zeros((4, 4)) affine[0, 0] = in_image.GetDirection()[0] * in_image.GetSpacing()[0] @@ -39,13 +38,11 @@ print('threshold', threshold) seg = run_tractseg(data=data, output_type=output_type, input_type="peaks", verbose=verbose, get_probs=get_probs, - dropout_sampling=dropout_sampling, threshold=threshold, postprocess=False) + dropout_sampling=dropout_sampling, threshold=threshold, postprocess=False, nr_cpus=1) - # bla = nib.Nifti1Image(seg, affine) - # nib.save(bla, '/home/neher/test.nii.gz') - if swapaxes: - print("Swapping axes back!") - seg = np.swapaxes(seg, 0, 2) +# bla = nib.Nifti1Image(seg, affine) +# nib.save(bla, '/home/neher/test.nii.gz') + seg = np.swapaxes(seg, 0, 2) print('Output shape: ' + str(seg.shape)) if output_type == "tract_segmentation": diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.python/src/internal/QmitkTractSegView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging.python/src/internal/QmitkTractSegView.cpp index 44aa39b..1083013 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging.python/src/internal/QmitkTractSegView.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging.python/src/internal/QmitkTractSegView.cpp @@ -201,6 +201,7 @@ void QmitkTractSegView::Start() // check for errors if(!m_PythonService->GetVariable("error_string").empty()) { + mitk::IPythonService::ForceLoadModule(); QMessageBox::warning(nullptr, "Error", QString(m_PythonService->GetVariable("error_string").c_str()), QMessageBox::Ok); return; } From 53428942c2507c311eba849e2520157abe98edb0 Mon Sep 17 00:00:00 2001 From: Peter Neher Date: Fri, 6 Dec 2019 13:01:36 +0100 Subject: [PATCH 3/3] UI updates --- .../QmitkFiberGenerationViewControls.ui | 24 +++++++++---------- PythonRequirements.txt | 2 +- README.md | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.fiberfox/src/internal/QmitkFiberGenerationViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging.fiberfox/src/internal/QmitkFiberGenerationViewControls.ui index 29f96f5..3536f99 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging.fiberfox/src/internal/QmitkFiberGenerationViewControls.ui +++ b/Plugins/org.mitk.gui.qt.diffusionimaging.fiberfox/src/internal/QmitkFiberGenerationViewControls.ui @@ -61,7 +61,7 @@ - 0 + 1 @@ -1034,7 +1034,7 @@ - Specify number of fibers to generate for the selected bundle. + Max. fiber twist per step (in degree) 0 @@ -1053,7 +1053,7 @@ - Specify number of fibers to generate for the selected bundle. + Min. fiber twist per step (in degree) 0 @@ -1115,7 +1115,7 @@ - Specify number of fibers to generate for the selected bundle. + Min. distance between fiducials (in mm) 1 @@ -1134,7 +1134,7 @@ - Specify number of fibers to generate for the selected bundle. + Max. distance between fiducials (in mm) 1 @@ -1175,7 +1175,7 @@ - Specify number of fibers to generate for the selected bundle. + Number of generated bundles 1 @@ -1234,7 +1234,7 @@ - Specify number of fibers to generate for the selected bundle. + Min. rotation between steps (in degree) 1 @@ -1253,7 +1253,7 @@ - Specify number of fibers to generate for the selected bundle. + Max. rotation between steps (in degree) 1 @@ -1415,7 +1415,7 @@ - Specify number of fibers to generate for the selected bundle. + Bundle radius 1 @@ -1434,7 +1434,7 @@ - Specify number of fibers to generate for the selected bundle. + Bundle radius 1 @@ -1477,7 +1477,7 @@ - Specify number of fibers to generate for the selected bundle. + <html><head/><body><p>Max. fibers per cm<span style=" vertical-align:super;">2</span></p></body></html> 1 @@ -1496,7 +1496,7 @@ - Specify number of fibers to generate for the selected bundle. + <html><head/><body><p>Min. fibers per cm<span style=" vertical-align:super;">2</span></p></body></html> 1 diff --git a/PythonRequirements.txt b/PythonRequirements.txt index b2d3e9d..a2443a8 100644 --- a/PythonRequirements.txt +++ b/PythonRequirements.txt @@ -3,7 +3,7 @@ SimpleITK dipy sklearn https://github.com/MIC-DKFZ/batchgenerators/archive/v0.19.5.zip -https://github.com/MIC-DKFZ/TractSeg/archive/v2.1.1.zip +https://github.com/MIC-DKFZ/TractSeg/archive/master.zip https://github.com/MIC-DKFZ/HD-BET/archive/master.zip torch torchvision diff --git a/README.md b/README.md index 5429a84..1e2d060 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ Automatically generated random fiber configuration for Fiberfox simulations. ## Building MITK Diffusion from source -* Install [Qt](https://www.qt.io/ Qt) on your system (>= 5.11.1). +* Install [Qt](https://www.qt.io/) on your system (>= 5.12.6). * Clone MITK from [github](https://github.com/MIC-DKFZ/MITK-Diffusion.git) using [Git version control](https://git-scm.com/). * Clone MITK Diffusion from [github](https://github.com/MITK/MITK.git). * Configure the MITK Superbuild using [CMake](https://cmake.org/) (>= 3.14.5).