Skip to content

Commit

Permalink
Merge branch 'master' of /space/freesurfer/repo/freesurfer
Browse files Browse the repository at this point in the history
Not sure what I'm doing here or if it is important.
  • Loading branch information
Doug Greve committed Feb 21, 2017
2 parents 4be5002 + 2c0dd3e commit adcba0d
Show file tree
Hide file tree
Showing 20 changed files with 460 additions and 11 deletions.
2 changes: 2 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions freeview/DialogPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
6 changes: 5 additions & 1 deletion freeview/LayerCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ bool LayerCollection::RemoveLayer( Layer* layer, bool deleteObject )

bool LayerCollection::RemoveLayers(QList<Layer *> layers)
{
int nLast = 0;
for ( int i = 0; i < m_layers.size(); i++ )
{
foreach (Layer* layer, layers)
Expand All @@ -173,15 +174,18 @@ bool LayerCollection::RemoveLayers(QList<Layer *> layers)
{
m_layers.erase( m_layers.begin() + i );
layer->deleteLater();
nLast = i;
i--;
break;
}
}
}
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)
{
Expand Down
3 changes: 2 additions & 1 deletion freeview/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ void MainWindow::LoadSettings()
}
else
{
((RenderView3D*)m_views[i])->GetCursor3D()->SetColor(m_settings["CursorColor"].value<QColor>());
((RenderView3D*)m_views[i])->GetCursor3D()->SetColor(m_settings["CursorColor"].value<QColor>());
((RenderView3D*)m_views[i])->GetInflatedSurfCursor()->SetColor(m_settings["CursorColor"].value<QColor>());
if (m_settings["CursorStyle"].toInt() < 2)
{
((RenderView3D*)m_views[i])->GetCursor3D()->SetLarge(m_settings["CursorStyle"].toInt());
Expand Down
4 changes: 2 additions & 2 deletions freeview/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
<x>0</x>
<y>0</y>
<width>1213</width>
<height>25</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -323,7 +323,6 @@
<addaction name="actionUndo"/>
<addaction name="actionRedo"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
Expand Down Expand Up @@ -430,6 +429,7 @@
<addaction name="separator"/>
<addaction name="actionPlot"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
Expand Down
12 changes: 9 additions & 3 deletions freeview/RenderView2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ void RenderView2D::StopSelection()
{
m_selection2D->Show( false );

QList<Layer*> layers = MainWindow::GetMainWindow()->GetSelectedLayers("MRI");
QList<Layer*> 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<LayerMRI*>(layers[i]);
Expand All @@ -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] );
Expand All @@ -382,6 +387,7 @@ void RenderView2D::StopSelection()
layer->GetProperty()->SetMinMaxGenericThreshold( range[0], range[1] );
break;
}
break;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions freeview/freeview.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nmovie_qt/RenderWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QMouseEvent>

RenderWidget::RenderWidget(QWidget *parent) :
QGLWidget(parent),
QWidget(parent),
m_bAutoResize(true),
m_nCurrentImageIndex(-1),
m_nInterval(40)
Expand Down
2 changes: 1 addition & 1 deletion nmovie_qt/RenderWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QTimer>
#include <QImage>

class RenderWidget : public QGLWidget
class RenderWidget : public QWidget
{
Q_OBJECT
public:
Expand Down
3 changes: 3 additions & 0 deletions nmovie_qt/nmovie.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

QT += core gui opengl

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets


TARGET = nmovie_qt
TEMPLATE = app

Expand Down
9 changes: 8 additions & 1 deletion scripts/mri_nu_correct.mni
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 22 additions & 0 deletions utils/test/MRIScomputeBorderValues/Makefile.am
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
138 changes: 138 additions & 0 deletions utils/test/MRIScomputeBorderValues/test_MRIScomputeBorderValues.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
//
// unit test for MRIScomputeBorderValues - located in utils/mrisurf.c
//

#include <string>
#include <iostream>
#include <iomanip>

#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);
}
1 change: 1 addition & 0 deletions utils/test/MRIScomputeBorderValues/testdata.tar.gz
Loading

0 comments on commit adcba0d

Please sign in to comment.