Skip to content

Commit b2afea8

Browse files
author
Douglas Greve
committed
Merge branch 'dev' of github.com:freesurfer/freesurfer into dev
2 parents 7bd7f90 + 5120c4f commit b2afea8

16 files changed

+1553
-671
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,3 +843,5 @@ if(BUILD_DNG)
843843
add_subdirectory(dngtester)
844844
endif()
845845

846+
# add wrapper for slicedelay
847+
install_pyscript(./scripts/slicedelay)

freeview/LayerTreeWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void LayerTreeWidget::contextMenuEvent(QContextMenuEvent *e)
268268
menu->addAction(wnd->ui->actionLoadPointSet);
269269
menu->addAction(wnd->ui->actionReloadPointSet);
270270
menu->addSeparator();
271-
if (wnd->GetMode() == RenderView::IM_VoxelEdit && ((LayerPointSet*)layer)->GetProperty()->GetShowSpline())
271+
if (wnd->GetMode() == RenderView::IM_VoxelEdit && type == "PointSet" && ((LayerPointSet*)layer)->GetProperty()->GetShowSpline())
272272
{
273273
QAction* act = new QAction("Convert to Volume Label", this);
274274
connect(act, SIGNAL(triggered(bool)), wnd, SLOT(OnPointSetToLabel()));

freeview/MainWindow.cpp

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ MainWindow::MainWindow( QWidget *parent, MyCmdLineParser* cmdParser ) :
197197
addAction(ui->actionDeleteLayer);
198198

199199
addAction(ui->actionNextLabelPoint);
200+
addAction(ui->actionShowLabelOutline);
200201

201202
#ifdef DISABLE_LINEPROF
202203
ui->actionLineProfile->setVisible(false);
@@ -808,7 +809,7 @@ void MainWindow::closeEvent( QCloseEvent * event )
808809
msg += "\nDo you still want to quit?";
809810
QMessageBox msgbox(this);
810811
msgbox.setIcon(QMessageBox::Question);
811-
QAbstractButton* yesBtn = msgbox.addButton("Quit", QMessageBox::YesRole);
812+
QAbstractButton* yesBtn = msgbox.addButton("Quit without Saving", QMessageBox::YesRole);
812813
msgbox.addButton("Cancel", QMessageBox::NoRole);
813814
msgbox.setText(msg);
814815
msgbox.setWindowTitle("Warning");
@@ -5739,9 +5740,12 @@ bool MainWindow::OnCloseVolume(const QList<Layer*>& layers_in)
57395740
{
57405741
if ( qobject_cast<LayerMRI*>(layer)->IsModified() )
57415742
{
5742-
if ( QMessageBox::question( this, "Volume Not Saved",
5743-
"Volume has been modifed and not been saved. Do you still want to continue?",
5744-
QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
5743+
QMessageBox box(QMessageBox::Question, tr("Close Volume"),
5744+
"Volume has been modifed and not been saved. Do you still want to continue?",
5745+
QMessageBox::Yes | QMessageBox::Cancel);
5746+
box.setButtonText(QMessageBox::Yes, tr("Continue Without Saving"));
5747+
box.setDefaultButton(QMessageBox::Cancel);
5748+
if (box.exec() != QMessageBox::Yes)
57455749
{
57465750
return false;
57475751
}
@@ -6169,9 +6173,12 @@ void MainWindow::OnCloseROI(const QList<Layer*>& layers_in)
61696173
{
61706174
if ( qobject_cast<LayerROI*>(layer)->IsModified() )
61716175
{
6172-
if ( QMessageBox::question( this, "ROI Not Saved",
6173-
"ROI has been modifed and not been saved. Do you still want to continue?",
6174-
QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
6176+
QMessageBox box(QMessageBox::Question, tr("Close ROI"),
6177+
"ROI has been modifed and not been saved. Do you still want to continue?",
6178+
QMessageBox::Yes | QMessageBox::Cancel);
6179+
box.setButtonText(QMessageBox::Yes, tr("Continue Without Saving"));
6180+
box.setDefaultButton(QMessageBox::Cancel);
6181+
if (box.exec() != QMessageBox::Yes)
61756182
{
61766183
return;
61776184
}
@@ -6388,9 +6395,12 @@ void MainWindow::OnClosePointSet(const QList<Layer*>& layers_in)
63886395
{
63896396
if ( qobject_cast<LayerPointSet*>(layer)->IsModified() )
63906397
{
6391-
if ( QMessageBox::question( this, "Point Set Not Saved",
6392-
"Point set has been modifed and not been saved. Do you still want to continue?",
6393-
QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
6398+
QMessageBox box(QMessageBox::Question, tr("Close Point Set"),
6399+
"Point Set has been modifed and not been saved. Do you still want to continue?",
6400+
QMessageBox::Yes | QMessageBox::Cancel);
6401+
box.setButtonText(QMessageBox::Yes, tr("Continue Without Saving"));
6402+
box.setDefaultButton(QMessageBox::Cancel);
6403+
if (box.exec() != QMessageBox::Yes)
63946404
{
63956405
return;
63966406
}
@@ -9868,3 +9878,12 @@ void MainWindow::SetNeurologicalView(bool b)
98689878
((RenderView2D*)m_views[i])->SetNeurologicalView(b);
98699879
}
98709880
}
9881+
9882+
void MainWindow::OnShowLabelOutline(bool bShow)
9883+
{
9884+
LayerMRI* mri = (LayerMRI*)GetLayerCollection( "MRI" )->GetActiveLayer();
9885+
if ( mri )
9886+
{
9887+
mri->GetProperty()->SetShowLabelOutline(bShow);
9888+
}
9889+
}

freeview/MainWindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,8 @@ protected slots:
632632

633633
void OnDeleteLayer();
634634

635+
void OnShowLabelOutline(bool bShow);
636+
635637
private:
636638
bool DoParseCommand(MyCmdLineParser* parser, bool bAutoQuit);
637639
void SaveSettings();

freeview/MainWindow.ui

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,17 @@
18621862
<string>Alt+O</string>
18631863
</property>
18641864
</action>
1865+
<action name="actionShowLabelOutline">
1866+
<property name="checkable">
1867+
<bool>true</bool>
1868+
</property>
1869+
<property name="text">
1870+
<string>Show Label Outline</string>
1871+
</property>
1872+
<property name="shortcut">
1873+
<string>Ctrl+L</string>
1874+
</property>
1875+
</action>
18651876
</widget>
18661877
<layoutdefault spacing="6" margin="11"/>
18671878
<customwidgets>
@@ -3861,6 +3872,22 @@
38613872
</hint>
38623873
</hints>
38633874
</connection>
3875+
<connection>
3876+
<sender>actionShowLabelOutline</sender>
3877+
<signal>toggled(bool)</signal>
3878+
<receiver>MainWindow</receiver>
3879+
<slot>OnShowLabelOutline(bool)</slot>
3880+
<hints>
3881+
<hint type="sourcelabel">
3882+
<x>-1</x>
3883+
<y>-1</y>
3884+
</hint>
3885+
<hint type="destinationlabel">
3886+
<x>606</x>
3887+
<y>435</y>
3888+
</hint>
3889+
</hints>
3890+
</connection>
38643891
</connections>
38653892
<slots>
38663893
<signal>CycleOverlayRequested()</signal>
@@ -3978,5 +4005,6 @@
39784005
<slot>OnCopyView()</slot>
39794006
<slot>OnDeleteLayer()</slot>
39804007
<slot>SetNeurologicalView(bool)</slot>
4008+
<slot>OnShowLabelOutline(bool)</slot>
39814009
</slots>
39824010
</ui>

freeview/PanelVolume.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ void PanelVolume::DoIdle()
354354
bool bDataAvail = (!strgs.isEmpty() && strgs[0] == FS_VOLUME_SETTING_ID);
355355
ui->actionPasteSetting->setEnabled(layer && bDataAvail);
356356
ui->actionPasteSettingToAll->setEnabled(layer && bDataAvail);
357+
ui->checkBoxShowOutline->setChecked(layer && layer->GetProperty()->GetShowLabelOutline());
357358
BlockAllSignals( false );
358359
}
359360

freeview/PanelVolume.ui

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,9 +1290,6 @@ of each frame</string>
12901290
<property name="text">
12911291
<string>Show label outline only (Ctrl+L)</string>
12921292
</property>
1293-
<property name="shortcut">
1294-
<string>Ctrl+L</string>
1295-
</property>
12961293
</widget>
12971294
</item>
12981295
<item>

freeview/RenderView2D.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ void RenderView2D::UpdateViewByWorldCoordinate()
217217
}
218218
// m_renderer->ResetCameraClippingRange();
219219
cam->SetParallelScale( qMax( qMax(m_dWorldSize[0], m_dWorldSize[1]), m_dWorldSize[2])/2 );
220+
Update2DOverlay();
220221
}
221222

222223
void RenderView2D::UpdateAnnotation()

include/MRISurfOverlay.h

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,54 @@
55
#include "mrisurf.h"
66

77
// list of Freesurfer surface overlays
8-
// the list for FS_MRISURFOVERLAY_STATS* is not complete
98
// the list should be mapped to INTENTS in GIFTI
109
#define FS_MRISURFOVERLAY_UNKNOWN -1
1110
#define FS_MRISURFOVERLAY_SHAPE 100
1211
#define FS_MRISURFOVERLAY_SHAPE_CURV 101
1312
#define FS_MRISURFOVERLAY_SHAPE_SULC 102
1413
#define FS_MRISURFOVERLAY_SHAPE_AREA 103
1514
#define FS_MRISURFOVERLAY_SHAPE_THICKNESS 104
15+
1616
#define FS_MRISURFOVERLAY_STATS 200
17-
#define FS_MRISURFOVERLAY_STATS_GAMMA 201
18-
#define FS_MRISURFOVERLAY_STATS_BETA 202
17+
#define FS_MRISURFOVERLAY_STATS_CORREL 201
18+
#define FS_MRISURFOVERLAY_STATS_TTEST 202
19+
#define FS_MRISURFOVERLAY_STATS_FTEST 203
20+
#define FS_MRISURFOVERLAY_STATS_ZSCORE 204
21+
#define FS_MRISURFOVERLAY_STATS_CHISQ 205
22+
#define FS_MRISURFOVERLAY_STATS_BETA 206
23+
#define FS_MRISURFOVERLAY_STATS_BINOM 207
24+
#define FS_MRISURFOVERLAY_STATS_GAMMA 208
25+
#define FS_MRISURFOVERLAY_STATS_POISSON 209
26+
#define FS_MRISURFOVERLAY_STATS_NORMAL 210
27+
#define FS_MRISURFOVERLAY_STATS_FTEST_NONC 211
28+
#define FS_MRISURFOVERLAY_STATS_CHISQ_NONC 212
29+
#define FS_MRISURFOVERLAY_STATS_LOGISTIC 213
30+
#define FS_MRISURFOVERLAY_STATS_LAPLACE 214
31+
#define FS_MRISURFOVERLAY_STATS_UNIFORM 215
32+
#define FS_MRISURFOVERLAY_STATS_TTEST_NONC 216
33+
#define FS_MRISURFOVERLAY_STATS_WEIBULL 217
34+
#define FS_MRISURFOVERLAY_STATS_CHI 218
35+
#define FS_MRISURFOVERLAY_STATS_INVGAUSS 219
36+
#define FS_MRISURFOVERLAY_STATS_EXTVAL 220
37+
#define FS_MRISURFOVERLAY_STATS_PVAL 221
38+
#define FS_MRISURFOVERLAY_STATS_LOGPVAL 222
39+
#define FS_MRISURFOVERLAY_STATS_LOG10PVAL 223
40+
#define FS_MRISURFOVERLAY_STATS_ESTIMATE 224
1941
// ...
2042

43+
struct OverlayInfoStruct
44+
{
45+
//char __foverlay[1024]; // full path to overlay file
46+
const char *__foverlay;
47+
int __type; // FS_MRISURFOVERLAY*
48+
const char *__datatype;// CurvatureRadial, SulcalDepth, Thickness, Area, (Volume, Jacobian)
49+
int __format; // MRI_CURV_FILE, MRI_MGH_FILE, GIFTI_FILE, ASCII_FILE, VTK_FILE
50+
int __stframe; // starting frame, this can be used when we combine multiple overlays in one MRI
51+
int __numframe; // for functions time series*, nframes can be > 1
52+
53+
int __nValsPerVertex = 1; // number of values at each vertex, should be 1
54+
};
55+
2156

2257
/* This class implements methods to read/write Freesurfer overlay files.
2358
* The following file formats are supported:
@@ -33,35 +68,48 @@
3368
class MRISurfOverlay
3469
{
3570
public:
36-
MRISurfOverlay();
71+
MRISurfOverlay(MRIS *mris, int noverlay, OverlayInfoStruct *poverlayInfo);
3772
~MRISurfOverlay();
3873

39-
MRI *read(const char *foverlay, int read_volume, MRIS *outmris=NULL); // MRISreadCurvatureFile()
40-
int write(const char *fout, MRIS *inmris=NULL); // MRISwriteCurvature()
74+
int read(int read_volume, MRIS *mris);
75+
int write(const char *fout, MRIS *inmris=NULL, bool mergegifti=false); // MRISwriteCurvature()
4176

42-
MRI *readCurvatureAsMRI(const char *curvfile, int read_volume);
77+
int getNumOverlay() { return __noverlay; }
78+
const char *getOverlayFilename(int nthOverlay) { return __overlayInfo[nthOverlay].__foverlay; }
79+
int getOverlayType(int nthOverlay) { return __overlayInfo[nthOverlay].__type; }
80+
int getGIFTIIntent(int nthOverlay);
81+
int getFirstFrameNo(int nthOverlay) { return __overlayInfo[nthOverlay].__stframe; }
82+
int getNumFrames(int nthOverlay) { return __overlayInfo[nthOverlay].__stframe + __overlayInfo[nthOverlay].__numframe; }
83+
const char *getDataType(int nthOverlay) { return __overlayInfo[nthOverlay].__datatype; }
4384

85+
// return overlay data in multi-frame MRI
86+
MRI *getOverlayMRI() { return __overlaymri; }
87+
4488
static int getFileFormat(const char *foverlay);
4589

4690
private:
91+
int __readOneOverlay(int nthOverlay, int read_volume, MRIS *mris); // MRISreadCurvatureFile()
4792
int __copyOverlay2MRIS(MRIS *outmris);
48-
int __readOldCurvature(MRIS *outmris, const char *fname);
93+
int __readCurvatureAsMRI(const char *curvfile, int read_volume);
94+
int __readOldCurvature(const char *fname);
4995

5096
int __writeCurvFromMRI(MRI *outmri, const char *fout);
5197
int __writeCurvFromMRIS(MRIS *outmris, const char *fout);
5298

53-
54-
char __foverlay[1024]; // full path to overlay file
55-
int __type; // not assigned yet, FS_MRISURFOVERLAY*
56-
int __format; // MRI_CURV_FILE, MRI_MGH_FILE, GIFTI_FILE
57-
int __stframe; // starting frame, this can be used when we combine multiple overlays in one MRI
58-
int __nframes; // for functions time series*, nframes can be > 1
59-
MRI *__overlaymri; // overlay data in MRI representation
99+
bool __isStatsData(int nthOverlay);
100+
bool __isShapeMeasurement(int nthOverlay);
60101

61102
int __nVertices;
62-
int __nFaces; // # of triangles, we need this for MRI_CURV_FILE output
63-
int __nValsPerVertex; // number of values at each vertex, should be 1
64-
};
103+
int __nFaces; // # of triangles, we need this for MRI_CURV_FILE output
65104

105+
int __noverlay;
106+
OverlayInfoStruct *__overlayInfo;
107+
108+
int __currOverlay;
109+
int __currFrame;
110+
111+
MRI *__overlaymri; // overlay data in MRI representation
112+
};
66113

67114
#endif
115+

include/gifti.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,28 @@
2525

2626
#include "gifti_io.h"
2727
#include "mrisurf.h"
28+
#include "MRISurfOverlay.h"
2829

29-
MRIS* mrisReadGIFTIfile(const char *fname, MRIS *mris);
30-
MRIS* mrisReadGIFTIdanum(const char *fname, MRIS *mris, int daNum);
30+
MRIS* mrisReadGIFTIfile(const char *fname, MRIS *mris, MRI *outmri=NULL, int *frame=NULL);
31+
MRIS* mrisReadGIFTIdanum(const char *fname, MRIS *mris, int daNum, MRI *outmri=NULL, int *frame=NULL);
3132
MRI* MRISreadGiftiAsMRI(const char *fname, int read_volume);
3233
int MRISwriteGIFTI(MRIS* mris, int intent_code, const char *out_fname, const char *curv_fname);
3334
int mriWriteGifti(MRI* mri, const char *out_fname);
3435

36+
// GIFTI intent related functions extracted from MRISwriteGIFTI()
37+
int MRISwriteGIFTIIntent(MRIS *mris, int intent_code, gifti_image *image, const char *out_fname, const char *curv_fname);
38+
int MRISwriteGIFTIShape(MRIS *mris, gifti_image *image, int intent_code, const char *curv_fname);
39+
int MRISwriteGIFTIStats(MRIS *mris, gifti_image *image, int intent_code);
40+
int MRISwriteGIFTILabel(MRIS *mris, gifti_image *image, int intent_code);
41+
int MRISwriteGIFTISurface(MRIS *mris, gifti_image *image, const char *out_fname);
42+
43+
// function to output multiple overlays
44+
int MRISwriteGIFTICombined(MRIS *mris, MRISurfOverlay *poverlays, const char *out_fname);
45+
// overloaded functions to handle combined GIFTI with multiple intents
46+
int MRISwriteGIFTIIntent(MRIS *mris, const MRI *mri, int stframe, int endframe, gifti_image *image, int intent_code, const char *out_fname, const char *curv_fname, const char *datatype);
47+
int MRISwriteGIFTIShape(MRIS *mris, const MRI *mri, int stframe, int endframe, gifti_image *image, int intent_code, const char *curv_fname, const char *datatype);
48+
int MRISwriteGIFTIStats(MRIS *mris, const MRI *mri, int stframe, int endframe, gifti_image *image, int intent_code, const char *curv_fname, const char *datatype);
49+
50+
51+
3552
#endif

include/mrisurf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,9 @@ int MRISreadCurvatureIntoArray(const char *fname,
657657
int MRISreadFloatFile(MRI_SURFACE *mris,const char *fname) ;
658658
#define MRISreadCurvature MRISreadCurvatureFile
659659

660-
int mrisReadAsciiCurvatureFile(MRI_SURFACE *mris, const char *fname);
660+
int mrisReadAsciiCurvatureFile(MRI_SURFACE *mris, const char *fname, MRI *outmri=NULL, int nframe=0);
661661
int mrisWriteAsciiCurvatureFile(MRI_SURFACE *mris, char *fname);
662-
MRI_SURFACE *MRISreadVTK(MRI_SURFACE *mris, const char *fname);
662+
MRI_SURFACE *MRISreadVTK(MRI_SURFACE *mris, const char *fname, MRI *outmri=NULL, int nframe=0);
663663

664664
MRI *MRISloadSurfVals(const char *srcvalfile,
665665
const char *typestring,

0 commit comments

Comments
 (0)