diff --git a/configure.in b/configure.in index 3503bbd37e8..e32a50b157a 100644 --- a/configure.in +++ b/configure.in @@ -4084,7 +4084,9 @@ AC_OUTPUT([Makefile utils/NrrdIO/Makefile utils/test/Makefile utils/test/mriBuildVoronoiDiagramFloat/Makefile + utils/test/MRIScomputeBorderValues/Makefile utils/test/mrishash/Makefile + utils/test/MRISpositionSurface/Makefile utils/test/mriSoapBubbleFloat/Makefile utilscpp/Makefile utilscpp/test/Makefile diff --git a/freeview/DialogPreferences.cpp b/freeview/DialogPreferences.cpp index 7dde47b8e13..3aa7bd99ee3 100644 --- a/freeview/DialogPreferences.cpp +++ b/freeview/DialogPreferences.cpp @@ -55,8 +55,12 @@ DialogPreferences::DialogPreferences(QWidget *parent) : } connect(ui->colorPickerCursor, SIGNAL(colorChanged(QColor)), ((RenderView3D*)mainwnd->GetRenderView(3))->GetCursor3D(), SLOT(SetColor(QColor))); + connect(ui->colorPickerCursor, SIGNAL(colorChanged(QColor)), + ((RenderView3D*)mainwnd->GetRenderView(3))->GetInflatedSurfCursor(), SLOT(SetColor(QColor))); connect(ui->comboBoxCursorStyle, SIGNAL(currentIndexChanged(int)), ((RenderView3D*)mainwnd->GetRenderView(3))->GetCursor3D(), SLOT(SetStyle(int))); + connect(ui->comboBoxCursorStyle, SIGNAL(currentIndexChanged(int)), + ((RenderView3D*)mainwnd->GetRenderView(3))->GetInflatedSurfCursor(), SLOT(SetStyle(int))); connect(ui->checkBoxSyncZoom, SIGNAL(toggled(bool)), mainwnd, SLOT(SyncZoom(bool))); connect(ui->radioButtonThemeDark, SIGNAL(toggled(bool)), diff --git a/freeview/LayerCollection.cpp b/freeview/LayerCollection.cpp index 24f50a65d5e..75b63a420d0 100644 --- a/freeview/LayerCollection.cpp +++ b/freeview/LayerCollection.cpp @@ -165,6 +165,7 @@ bool LayerCollection::RemoveLayer( Layer* layer, bool deleteObject ) bool LayerCollection::RemoveLayers(QList layers) { + int nLast = 0; for ( int i = 0; i < m_layers.size(); i++ ) { foreach (Layer* layer, layers) @@ -173,6 +174,7 @@ bool LayerCollection::RemoveLayers(QList layers) { m_layers.erase( m_layers.begin() + i ); layer->deleteLater(); + nLast = i; i--; break; } @@ -180,8 +182,10 @@ bool LayerCollection::RemoveLayers(QList layers) } if (m_layers.isEmpty()) SetActiveLayer(NULL); + else if (nLast < m_layers.size()) + SetActiveLayer(m_layers[nLast]); else - SetActiveLayer(m_layers[0]); + SetActiveLayer(m_layers[m_layers.size()-1]); foreach (Layer* layer, layers) { diff --git a/freeview/MainWindow.cpp b/freeview/MainWindow.cpp index a1178d44e36..e69957de3fc 100644 --- a/freeview/MainWindow.cpp +++ b/freeview/MainWindow.cpp @@ -552,7 +552,8 @@ void MainWindow::LoadSettings() } else { - ((RenderView3D*)m_views[i])->GetCursor3D()->SetColor(m_settings["CursorColor"].value()); + ((RenderView3D*)m_views[i])->GetCursor3D()->SetColor(m_settings["CursorColor"].value()); + ((RenderView3D*)m_views[i])->GetInflatedSurfCursor()->SetColor(m_settings["CursorColor"].value()); if (m_settings["CursorStyle"].toInt() < 2) { ((RenderView3D*)m_views[i])->GetCursor3D()->SetLarge(m_settings["CursorStyle"].toInt()); diff --git a/freeview/MainWindow.ui b/freeview/MainWindow.ui index dad2ce00f13..0a0dd9d7899 100644 --- a/freeview/MainWindow.ui +++ b/freeview/MainWindow.ui @@ -254,7 +254,7 @@ 0 0 1213 - 25 + 20 @@ -323,7 +323,6 @@ - @@ -430,6 +429,7 @@ + diff --git a/freeview/RenderView2D.cpp b/freeview/RenderView2D.cpp index 7df744e0023..e931f5acdcc 100644 --- a/freeview/RenderView2D.cpp +++ b/freeview/RenderView2D.cpp @@ -359,7 +359,10 @@ void RenderView2D::StopSelection() { m_selection2D->Show( false ); - QList layers = MainWindow::GetMainWindow()->GetSelectedLayers("MRI"); + QList layers; + if (MainWindow::GetMainWindow()->GetCurrentLayerType() == "MRI") + layers = MainWindow::GetMainWindow()->GetSelectedLayers("MRI"); + layers << MainWindow::GetMainWindow()->GetLayers("MRI"); for (int i = 0; i < layers.size(); i++) { LayerMRI* layer = qobject_cast(layers[i]); @@ -368,9 +371,11 @@ void RenderView2D::StopSelection() double range[2], m_dPt0[3], m_dPt2[3]; m_selection2D->GetWorldPoint( 0, m_dPt0 ); m_selection2D->GetWorldPoint( 2, m_dPt2 ); - if ( layer->GetVoxelValueRange( m_dPt0, m_dPt2, m_nViewPlane, range ) ) + int nColorMap = layer->GetProperty()->GetColorMap(); + if (layer->IsVisible() && nColorMap != LayerPropertyMRI::LUT && + nColorMap != LayerPropertyMRI::DirectionCoded && layer->GetVoxelValueRange( m_dPt0, m_dPt2, m_nViewPlane, range ) ) { - switch ( layer->GetProperty()->GetColorMap() ) + switch ( nColorMap ) { case LayerPropertyMRI::Grayscale: layer->GetProperty()->SetMinMaxGrayscaleWindow( range[0], range[1] ); @@ -382,6 +387,7 @@ void RenderView2D::StopSelection() layer->GetProperty()->SetMinMaxGenericThreshold( range[0], range[1] ); break; } + break; } } } diff --git a/freeview/freeview.pro b/freeview/freeview.pro index b6e5b0d9491..c5bfbda4dec 100755 --- a/freeview/freeview.pro +++ b/freeview/freeview.pro @@ -454,6 +454,8 @@ RC_FILE = resource/icons/freeview.icns greaterThan(QT_MAJOR_VERSION, 4): QT -= x11extras script +QMAKE_CXXFLAGS += -DVCL_CAN_STATIC_CONST_INIT_FLOAT=0 + QMAKE_CXXFLAGS -= -DHAVE_OPENMP QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 diff --git a/nmovie_qt/RenderWidget.cpp b/nmovie_qt/RenderWidget.cpp index d7bb6c5282f..6952ea13f44 100644 --- a/nmovie_qt/RenderWidget.cpp +++ b/nmovie_qt/RenderWidget.cpp @@ -5,7 +5,7 @@ #include RenderWidget::RenderWidget(QWidget *parent) : - QGLWidget(parent), + QWidget(parent), m_bAutoResize(true), m_nCurrentImageIndex(-1), m_nInterval(40) diff --git a/nmovie_qt/RenderWidget.h b/nmovie_qt/RenderWidget.h index d870ecb605f..6d839539d0b 100644 --- a/nmovie_qt/RenderWidget.h +++ b/nmovie_qt/RenderWidget.h @@ -5,7 +5,7 @@ #include #include -class RenderWidget : public QGLWidget +class RenderWidget : public QWidget { Q_OBJECT public: diff --git a/nmovie_qt/nmovie.pro b/nmovie_qt/nmovie.pro index f12a9998b5c..a39adc4b143 100644 --- a/nmovie_qt/nmovie.pro +++ b/nmovie_qt/nmovie.pro @@ -6,6 +6,9 @@ QT += core gui opengl +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + + TARGET = nmovie_qt TEMPLATE = app diff --git a/scripts/mri_nu_correct.mni b/scripts/mri_nu_correct.mni index cb8bfc621ac..c866dfd4be5 100755 --- a/scripts/mri_nu_correct.mni +++ b/scripts/mri_nu_correct.mni @@ -89,7 +89,14 @@ if($status) then exit 1; endif -if(! $#tmpdir) set tmpdir = $OutDir/tmp.mri_nu_correct.mni.$$ +# check for existence of /dev/shm +set templocation = $OutDir +if (-d /dev/shm) then + echo "Found /dev/shm , will use for temp dir" | tee -a $LF + set templocation = "/dev/shm" +endif + +if(! $#tmpdir) set tmpdir = $templocation/tmp.mri_nu_correct.mni.$$ mkdir -p $tmpdir echo "tmpdir is $tmpdir" | tee -a $LF diff --git a/utils/test/MRIScomputeBorderValues/Makefile.am b/utils/test/MRIScomputeBorderValues/Makefile.am new file mode 100644 index 00000000000..788b453a47c --- /dev/null +++ b/utils/test/MRIScomputeBorderValues/Makefile.am @@ -0,0 +1,22 @@ +## +## Makefile.am +## + +AM_CPPFLAGS=-I$(top_srcdir)/include +AM_LDFLAGS= + +check_PROGRAMS = test_MRIScomputeBorderValues + +TESTS=run_test_MRIScomputeBorderValues + +test_MRIScomputeBorderValues_SOURCES=test_MRIScomputeBorderValues.cpp +test_MRIScomputeBorderValues_LDADD= $(addprefix $(top_builddir)/, $(LIBS_MGH)) +test_MRIScomputeBorderValues_LDFLAGS= $(OS_LDFLAGS) + +EXTRA_DIST=run_test_MRIScomputeBorderValues testdata.tar.gz + +EXCLUDE_FILES= +include $(top_srcdir)/Makefile.extra + +clean-local: + rm -f *.o diff --git a/utils/test/MRIScomputeBorderValues/run_test_MRIScomputeBorderValues b/utils/test/MRIScomputeBorderValues/run_test_MRIScomputeBorderValues new file mode 100755 index 00000000000..b033a2947c4 --- /dev/null +++ b/utils/test/MRIScomputeBorderValues/run_test_MRIScomputeBorderValues @@ -0,0 +1,52 @@ +#!/bin/tcsh -f +# +# unit test for: MRIScomputeBorderValues +# - this script provides source and reference data for the testing binary +# + + +umask 002 + +# extract testing data: +gunzip -c testdata.tar.gz | tar xvf - + + +# +# run test_MRIScomputeBorderValues with the source and reference files: +# + +cd testdata + +setenv FREESURFER_HOME ../../distribution +setenv SUBJECTS_DIR "" + + +set threads=( 1 8 ) +foreach num ($threads) + + setenv OMP_NUM_THREADS $num + echo + echo "running test_MRIScomputeBorderValues with $num thread(s)" + + set cmd=(../test_MRIScomputeBorderValues lh.surf mri_brain.mgz mri_smooth.mgz mri_aseg.mgz) + echo + $cmd + if ($status != 0) then + echo "test_MRIScomputeBorderValues FAILED" + exit 1 + endif + +end + +echo +echo +echo + + +# cleanup: +cd .. +rm -rf testdata + +echo +echo "MRIScomputeBorderValues passed test" +exit 0 diff --git a/utils/test/MRIScomputeBorderValues/test_MRIScomputeBorderValues.cpp b/utils/test/MRIScomputeBorderValues/test_MRIScomputeBorderValues.cpp new file mode 100644 index 00000000000..240fae41b32 --- /dev/null +++ b/utils/test/MRIScomputeBorderValues/test_MRIScomputeBorderValues.cpp @@ -0,0 +1,138 @@ +// +// unit test for MRIScomputeBorderValues - located in utils/mrisurf.c +// + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ + #endif + + #include "error.h" + #include "utils.h" + #include "macros.h" + #include "mri.h" + #include "mrisurf.h" + + #ifdef __cplusplus +} +#endif + +int main(int argc, char *argv[]) +{ + int err = 0; + + // check arg count: + if (argc != 5) + { + std::cerr << "ERROR: 4 args are required: mris mri_brain mri_smooth mri_aseg\n"; + exit(1); + } + + + // read args: + std::string Progname = argv[0]; + std::string s_mris = argv[1]; + std::string s_brain = argv[2]; + std::string s_smooth = argv[3]; + std::string s_aseg = argv[4]; + + std::cout << Progname << std::endl; + + + // read MRIS input: + std::cout << "reading " << s_mris << std::endl; + MRIS *mris = MRISread(s_mris.c_str()); + if (!mris) + { + std::cerr << "ERROR: could not read mris '" << s_mris << "'!\n"; + exit(ERROR_BADPARM); + } + // read MRI_BRAIN input: + std::cout << "reading " << s_brain << std::endl; + MRI *mri_brain = MRIread(s_brain.c_str()); + if (!mri_brain) + { + std::cerr << "ERROR: could not read mri_brain '" << s_brain << "'!\n"; + exit(ERROR_BADPARM); + } + // read MRI_SMOOTH input: + std::cout << "reading " << s_smooth << std::endl; + MRI *mri_smooth = MRIread(s_smooth.c_str()); + if (!mri_smooth) + { + std::cerr << "ERROR: could not read mri_smooth '" << s_smooth << "'!\n"; + exit(ERROR_BADPARM); + } + // read MRI_ASEG input: + std::cout << "reading " << s_aseg << std::endl; + MRI *mri_aseg = MRIread(s_aseg.c_str()); + if (!mri_aseg) + { + std::cerr << "ERROR: could not read mri_aseg '" << s_aseg << "'!\n"; + exit(ERROR_BADPARM); + } + + + // run: + std::cout << "running MRIScomputeBorderValues...\n"; + err = MRIScomputeBorderValues(mris, mri_brain, mri_smooth, + 120.0, 112.28, 64.0, 53.24, 112.28, + 1.0, 10.0, NULL, 1, NULL, 0.0, 0, mri_aseg); + if (err) + { + std::cerr << "ERROR: could not run MRIScomputeBorderValues!\n"; + exit(err); + } + + + // check averages of val, d, and mean across all vertices with nonzero val: + int vno, vtot = 0; + VERTEX *v; + float val_sum = 0, d_sum = 0, mean_sum = 0; + float val_avg, d_avg, mean_avg; + + for (vno = 0 ; vno < mris->nvertices ; vno++) + { + v = &mris->vertices[vno]; + if (!FZERO(v->val)) + { + val_sum += v->val; + d_sum += v->d; + mean_sum += v->mean; + + vtot++; + } + } + + val_avg = val_sum / vtot; + d_avg = d_sum / vtot; + mean_avg = mean_sum / vtot; + + std::cout << "\ncomputing stats for comparison:\n"; + std::cout << std::fixed; + std::cout << std::setprecision(8); + std::cout << "avg val: " << val_avg << std::endl; + std::cout << "avg d: " << d_avg << std::endl; + std::cout << "avg mean: " << mean_avg << std::endl; + + if (!FEQUAL(val_avg, 80.10114288)) { err = 1; } + if (!FEQUAL(d_avg, -0.26251045)) { err = 1; } + if (!FEQUAL(mean_avg, 6.81254005)) { err = 1; } + if (err == 1) + { + std::cout << "surface vertex stats DO NOT match reference data!\n"; + } + + + // shut down: + MRISfree(&mris); + MRIfree(&mri_brain); + MRIfree(&mri_smooth); + MRIfree(&mri_aseg); + + exit(err); +} \ No newline at end of file diff --git a/utils/test/MRIScomputeBorderValues/testdata.tar.gz b/utils/test/MRIScomputeBorderValues/testdata.tar.gz new file mode 120000 index 00000000000..7bd56e5578f --- /dev/null +++ b/utils/test/MRIScomputeBorderValues/testdata.tar.gz @@ -0,0 +1 @@ +../../../.git/annex/objects/QZ/9J/SHA256E-s4936477--7f6ee280388db93e286ded9f2a2c44ac236d556d44e8be56c505c17250c71911.tar.gz/SHA256E-s4936477--7f6ee280388db93e286ded9f2a2c44ac236d556d44e8be56c505c17250c71911.tar.gz \ No newline at end of file diff --git a/utils/test/MRISpositionSurface/Makefile.am b/utils/test/MRISpositionSurface/Makefile.am new file mode 100644 index 00000000000..2a9ed98ce16 --- /dev/null +++ b/utils/test/MRISpositionSurface/Makefile.am @@ -0,0 +1,22 @@ +## +## Makefile.am +## + +AM_CPPFLAGS=-I$(top_srcdir)/include +AM_LDFLAGS= + +check_PROGRAMS = test_MRISpositionSurface + +TESTS=run_test_MRISpositionSurface + +test_MRISpositionSurface_SOURCES=test_MRISpositionSurface.cpp +test_MRISpositionSurface_LDADD= $(addprefix $(top_builddir)/, $(LIBS_MGH)) +test_MRISpositionSurface_LDFLAGS= $(OS_LDFLAGS) + +EXTRA_DIST=run_test_MRISpositionSurface testdata.tar.gz + +EXCLUDE_FILES= +include $(top_srcdir)/Makefile.extra + +clean-local: + rm -f *.o diff --git a/utils/test/MRISpositionSurface/run_test_MRISpositionSurface b/utils/test/MRISpositionSurface/run_test_MRISpositionSurface new file mode 100755 index 00000000000..2a3669ac185 --- /dev/null +++ b/utils/test/MRISpositionSurface/run_test_MRISpositionSurface @@ -0,0 +1,52 @@ +#!/bin/tcsh -f +# +# unit test for: MRISpositionSurface +# - this script provides source and reference data for the testing binary +# + + +umask 002 + +# extract testing data: +gunzip -c testdata.tar.gz | tar xvf - + + +# +# run test_MRISpositionSurface with the source and reference files: +# + +cd testdata + +setenv FREESURFER_HOME ../../distribution +setenv SUBJECTS_DIR "" + + +set threads=( 1 8 ) +foreach num ($threads) + + setenv OMP_NUM_THREADS $num + echo + echo "running test_MRISpositionSurface with $OMP_NUM_THREADS thread(s)" + + set cmd=(../test_MRISpositionSurface lh.surf mri_brain.mgz mri_smooth.mgz) + echo + $cmd + if ($status != 0) then + echo "test_MRISpositionSurface FAILED" + exit 1 + endif + +end + +echo +echo +echo + + +# cleanup: +cd .. +rm -rf testdata + +echo +echo "MRISpositionSurface passed test" +exit 0 diff --git a/utils/test/MRISpositionSurface/test_MRISpositionSurface.cpp b/utils/test/MRISpositionSurface/test_MRISpositionSurface.cpp new file mode 100644 index 00000000000..858b04a9b95 --- /dev/null +++ b/utils/test/MRISpositionSurface/test_MRISpositionSurface.cpp @@ -0,0 +1,130 @@ +// +// unit test for MRISpositionSurface - located in utils/mrisurf.c +// + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ + #endif + + #include "error.h" + #include "utils.h" + #include "macros.h" + #include "mri.h" + #include "mrisurf.h" + + #ifdef __cplusplus +} +#endif + +int main(int argc, char *argv[]) +{ + int err = 0; + + // check arg count: + if (argc != 4) + { + std::cerr << "ERROR: 3 args are required: mris mri_brain mri_smooth\n"; + exit(1); + } + + + // read args: + std::string Progname = argv[0]; + std::string s_mris = argv[1]; + std::string s_brain = argv[2]; + std::string s_smooth = argv[3]; + + std::cout << Progname << std::endl; + + + // read MRIS input: + std::cout << "reading " << s_mris << std::endl; + MRIS *mris = MRISread(s_mris.c_str()); + if (!mris) + { + std::cerr << "ERROR: could not read mris '" << s_mris << "'!\n"; + exit(ERROR_BADPARM); + } + // read MRI_BRAIN input: + std::cout << "reading " << s_brain << std::endl; + MRI *mri_brain = MRIread(s_brain.c_str()); + if (!mri_brain) + { + std::cerr << "ERROR: could not read mri_brain '" << s_brain << "'!\n"; + exit(ERROR_BADPARM); + } + // read MRI_SMOOTH input: + std::cout << "reading " << s_smooth << std::endl; + MRI *mri_smooth = MRIread(s_smooth.c_str()); + if (!mri_smooth) + { + std::cerr << "ERROR: could not read mri_smooth '" << s_smooth << "'!\n"; + exit(ERROR_BADPARM); + } + + // set up integration parms: + INTEGRATION_PARMS parms; + memset(&parms, 0, sizeof(parms)); + + parms.fill_interior = 0; + parms.projection = NO_PROJECTION; + parms.tol = 1e-4; + parms.dt = 0.5f; + parms.base_dt = parms.dt; + parms.l_curv = 1.0; + parms.l_intensity = 0.2; + parms.l_spring = 1.0f; + parms.l_tspring = 1.0f; + parms.l_nspring = 0.5f; + parms.niterations = 20; + parms.start_t = 0; + parms.write_iterations = 0; + parms.integration_type = INTEGRATE_MOMENTUM; + parms.momentum = 0.0; + parms.dt_increase = 1.0; + parms.dt_decrease = 0.50; + parms.error_ratio = 50.0; + parms.l_surf_repulse = 0.0; + parms.l_repulse = 5; + parms.sigma = 0.2f; + parms.n_averages = 10; + + + + // run: + std::cout << "running MRISpositionSurface...\n"; + err = MRISpositionSurface(mris, mri_brain, mri_smooth, &parms); + if (err) + { + std::cerr << "ERROR: could not run MRISpositionSurface!\n"; + exit(err); + } + + + // compare data: + VERTEX *v; + + v = &mris->vertices[160]; + if (!FEQUAL(v->dist[0], 1.36991000f)) { err = 1; } + v = &mris->vertices[1170]; + if (!FEQUAL(v->dist[0], 1.10133839f)) { err = 1; } + v = &mris->vertices[720]; + if (!FEQUAL(v->dist[0], 1.51904464f)) { err = 1; } + if (err == 1) + { + std::cout << "surface vertex stats DO NOT match reference data!\n"; + } + + + // shut down: + MRISfree(&mris); + MRIfree(&mri_brain); + MRIfree(&mri_smooth); + + exit(err); +} diff --git a/utils/test/MRISpositionSurface/testdata.tar.gz b/utils/test/MRISpositionSurface/testdata.tar.gz new file mode 120000 index 00000000000..2911bebfe76 --- /dev/null +++ b/utils/test/MRISpositionSurface/testdata.tar.gz @@ -0,0 +1 @@ +../../../.git/annex/objects/47/8k/SHA256E-s4738840--fa634cc5a1f12c86143643fc21c866b896bb20a0ea5c263145b9564de1811c86.tar.gz/SHA256E-s4738840--fa634cc5a1f12c86143643fc21c866b896bb20a0ea5c263145b9564de1811c86.tar.gz \ No newline at end of file diff --git a/utils/test/Makefile.am b/utils/test/Makefile.am index 343d99c5858..f013749c7ee 100644 --- a/utils/test/Makefile.am +++ b/utils/test/Makefile.am @@ -2,8 +2,10 @@ # Makefile.am # SUBDIRS=mriBuildVoronoiDiagramFloat \ + MRIScomputeBorderValues \ mrishash \ - mriSoapBubbleFloat + MRISpositionSurface \ + mriSoapBubbleFloat AM_CPPFLAGS=-I$(top_srcdir)/include \ -I$(top_srcdir)/include/dicom \