Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:freesurfer/freesurfer into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Greve committed Jan 25, 2022
2 parents eb82742 + aef1a6b commit 8f6aeea
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 254 deletions.
3 changes: 2 additions & 1 deletion freeview/DialogLoadVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void DialogLoadVolume::UpdateLUT()
void DialogLoadVolume::OnOpen()
{
QString fn = ui->comboBoxFilenames->currentText().trimmed();
if (fn == "current folder")
if (fn.isEmpty() || fn == "current folder")
fn = QDir::currentPath();
else
fn = QFileInfo(fn).absolutePath();
Expand Down Expand Up @@ -107,6 +107,7 @@ void DialogLoadVolume::SetRecentFiles( const QStringList& filenames )
if ( !filenames.isEmpty() )
{
ui->comboBoxFilenames->setCurrentIndex( 0 );
ui->comboBoxFilenames->setCurrentText("");
ui->comboBoxFilenames->lineEdit()->setCursorPosition( ui->comboBoxFilenames->currentText().size() );
}
}
Expand Down
50 changes: 47 additions & 3 deletions freeview/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,11 @@ void MainWindow::RunScript()
}
else if ( cmd == "setheatscaleoptions" )
{
CommandSetHeadScaleOptions( sa );
CommandSetHeatScaleOptions( sa );
}
else if ( cmd == "setheatscaleoffset")
{
CommandSetHeatScaleOffset( sa );
}
else if ( cmd == "setlut" )
{
Expand Down Expand Up @@ -2152,6 +2156,10 @@ void MainWindow::RunScript()
{
CommandSetActiveFrame(sa);
}
else if (cmd == "setautoadjustframecontrast")
{
CommandSetAutoAdjustFrameContrast(sa);
}
else if (cmd == "setactivelayer")
{
CommandSetActiveLayer(sa);
Expand Down Expand Up @@ -2376,12 +2384,18 @@ void MainWindow::CommandLoadVolume( const QStringList& sa )
scales = subArgu.split(",");
}
else if ( subOption == "heatscaleoption" ||
subOption == "heatscaleoptions" )
subOption == "heatscaleoptions" ||
subOption == "heatscale_option" ||
subOption == "heatscale_options")
{
QStringList script("setheatscaleoptions");
script << subArgu.split(",");
m_scripts.insert( 0, script );
}
else if ( subOption == "heatscale_offset" )
{
m_scripts.insert( 0, QStringList() << "setheatscaleoffset" << subArgu );
}
else if ( subOption == "lut" )
{
lut_name = subArgu;
Expand Down Expand Up @@ -2584,6 +2598,10 @@ void MainWindow::CommandLoadVolume( const QStringList& sa )
{
m_scripts.insert( 0, QStringList() << "setactiveframe" << subArgu );
}
else if ( subOption == "auto_adjust_frame_contrast" )
{
m_scripts.insert( 0, QStringList() << "setautoadjustframecontrast" << subArgu );
}
else if (subOption == "ignore_header")
{
sup_data["IgnoreHeader"] = true;
Expand Down Expand Up @@ -2775,7 +2793,7 @@ void MainWindow::CommandSetSelectedLabels(const QStringList &cmd)
}
}

void MainWindow::CommandSetHeadScaleOptions( const QStringList& sa )
void MainWindow::CommandSetHeatScaleOptions( const QStringList& sa )
{
if ( GetLayerCollection( "MRI" )->GetActiveLayer() )
{
Expand All @@ -2794,6 +2812,22 @@ void MainWindow::CommandSetHeadScaleOptions( const QStringList& sa )
}
}

void MainWindow::CommandSetHeatScaleOffset(const QStringList &sa)
{
if ( GetLayerCollection( "MRI" )->GetActiveLayer() )
{
bool bOK;
double dValue = sa[1].toDouble(&bOK);
if ( !bOK )
{
cerr << "Heatscale offset value is not valid.\n";
return;
}
LayerPropertyMRI* p = ( (LayerMRI*)GetLayerCollection( "MRI" )->GetActiveLayer() )->GetProperty();
p->SetHeatScaleOffset(dValue);
}
}

void MainWindow::CommandSetLayerName( const QStringList& cmd )
{
if ( cmd.size() > 2 )
Expand Down Expand Up @@ -3117,6 +3151,16 @@ void MainWindow::CommandSetActiveFrame( const QStringList& sa )
}
}

void MainWindow::CommandSetAutoAdjustFrameContrast( const QStringList& sa )
{
LayerMRI* mri = (LayerMRI*)GetLayerCollection( "MRI" )->GetActiveLayer();
if ( mri )
{
mri->GetProperty()->SetAutoAdjustFrameLevel(sa[1].toLower() == "true" || sa[1] == "1");
}
}


void MainWindow::CommandSetDisplayIsoSurface( const QStringList& sa )
{
LayerMRI* mri = (LayerMRI*)GetLayerCollection( "MRI" )->GetActiveLayer();
Expand Down
4 changes: 3 additions & 1 deletion freeview/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ public slots:
void CommandWriteSurfaceIntersection( const QStringList& cmd);
void CommandSetColorMap ( const QStringList& cmd );
void CommandSetLUT ( const QStringList& cmd );
void CommandSetHeadScaleOptions( const QStringList& sa );
void CommandSetHeatScaleOptions( const QStringList& sa );
void CommandSetHeatScaleOffset ( const QStringList& sa );
void CommandSetOpacity ( const QStringList& cmd );
void CommandSetLabelOutline ( const QStringList& cmd );
void CommandSetSelectedLabels (const QStringList& cmd);
Expand Down Expand Up @@ -441,6 +442,7 @@ public slots:
void CommandReorderLayers ( const QStringList& cmd );
void CommandUnloadLayers ( const QStringList& cmd );
void CommandSetActiveFrame ( const QStringList& cmd );
void CommandSetAutoAdjustFrameContrast ( const QStringList& cmd );
void CommandSetActiveLayer ( const QStringList& cmd );
void CommandExportLineProfileThickness (const QStringList& cmd);
void CommandSetVolumeTrackFrame ( const QStringList& cmd );
Expand Down
4 changes: 3 additions & 1 deletion freeview/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ int main(int argc, char *argv[])
"':colormap=name' Set colormap for display. Valid names are grayscale/lut/heat/jet/gecolor/nih/pet/binary. \n\n"
"':grayscale=min,max' Set grayscale window values.\n\n"
"':heatscale=min,mid,max' Set heat scale values. If only 2 values given, min and mid will be set to the same value.\n\n"
"':heatscaleoptions=option1[,option2]' Set heat scale options. Options can be 'truncate','invert', or both.\n\n"
"':heatscale_options=option1[,option2]' Set heat scale options. Options can be 'truncate','invert', or both.\n\n"
"':heatscale_offset=val' Set heat scale offset value.\n\n"
"':colorscale=min,max' Set generic colorscale values for jet/gecolor/nih/pet.\n\n"
"':lut=name' Set lookup table to the given name. Name can be the name of a stock color table or the filename of a color table file.\n\n"
"':binary_color=color' Set the color of the non-zero voxels. Colormap must be set to binary. Color can be a color name such as 'red' or 3 values as RGB components of the color, e.g., '255,0,0'.\n\n"
Expand Down Expand Up @@ -176,6 +177,7 @@ int main(int argc, char *argv[])
"':structure=name_or_value' Move the slice in the main viewport to where it has the most of the given structure.\n\n"
"':ignore_header=flag' Ignore header information. Use the existing volume's header info. Flag can be '1' or '0' or 'true' or 'false'.\n\n"
"':frame=number' Set active frame (0 based).\n\n"
"':auto_adjust_frame_contrast=flag' Set flag for automatically adjust frame contrast. Flag can be '1' or 'true'.\n\n"
"':select_label=label_index' When colormap is set as look up table, select and show only the given labels. Multiple labels can be given separated by comma, such as, '5,10,20'.\n\n"
"Example:\nfreeview -v T1.mgz:colormap=heatscale:heatscale=10,100,200\n", 1, 1000 ),
CmdLineEntry( CMD_LINE_SWITCH, "r", "resample", "", "Resample oblique data to standard RAS." ),
Expand Down
55 changes: 34 additions & 21 deletions include/GradUnwarp.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,58 @@ typedef struct
char xyz;
} COEFF;

class Siemens_B
{
public:
Siemens_B(int coeffDim0, int nmax0, float R0, double **normfact0, float X, float Y, float Z);
~Siemens_B();

float siemens_B_x(float **Alpha_x, float **Beta_x);
float siemens_B_y(float **Alpha_y, float **Beta_y);
float siemens_B_z(float **Alpha_z, float **Beta_z);
float siemens_B(float **Alpha, float **Beta);
void siemens_legendre(int n, double x);

private:
int coeffDim;
int nmax;
float R0_mm;

double **normfact;

double **P;
float *F;
double *cosPhi, *sinPhi;
float R, Theta, Phi;
};

class GradUnwarp
{
public:
GradUnwarp();
~GradUnwarp();

void setup();
void list_coeff_files();
void setup() {};
void list_coeff_files() {};

void read_siemens_coeff(const char *gradfilename);
void printCoeff();

float siemens_B_x();
float siemens_B_y();
float siemens_B_z();
float siemens_B(float **Alpha, float **Beta, float **F2);
void siemens_B0(float X, float Y, float Z);
void siemens_legendre(int n, double x, double **P);

void initSiemensLegendreNormfact();
void spharm_evaluate(float X, float Y, float Z, float *Dx, float *Dy, float *Dz);

void initSiemensLegendreNormfact();

void unwarp();
void unwap_volume();
void unwarp_surface();
void unwarp() {};
void unwap_volume() {};
void unwarp_surface() {};

private:
FILE *fgrad;

COEFF coeff[100];

int nmax;
int mmax;

int coeffCount;
int coeffDim;

Expand All @@ -56,13 +76,6 @@ class GradUnwarp
double *factorials;
double **normfact;

// these are reset and re-calculated for each (x, y, z) in siemens_B0()
double **P;
float **F2_x, **F2_y, **F2_z;
float *F;
double *cosPhi, *sinPhi;
float R, Theta, Phi;

private:
void _skipCoeffComment();
void _initCoeff();
Expand Down
Loading

0 comments on commit 8f6aeea

Please sign in to comment.