本文整理汇总了C++中VolumeCollection::SetFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ VolumeCollection::SetFileName方法的具体用法?C++ VolumeCollection::SetFileName怎么用?C++ VolumeCollection::SetFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VolumeCollection
的用法示例。
在下文中一共展示了VolumeCollection::SetFileName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char **argv ) {
try {
QApplication a( argc, argv );
string fnMRI = "/Users/kteich/work/subjects/bert/mri/orig";
char* sSubjectsDir = getenv("SUBJECTS_DIR");
if ( NULL != sSubjectsDir ) {
fnMRI = string(sSubjectsDir) + "/bert/mri/orig";
}
if ( argc == 2 ) {
fnMRI = argv[1];
}
VolumeCollection vol;
vol.SetFileName( fnMRI );
MRI* mri = vol.GetMRI();
if ( NULL == mri )
exit( 1 );
QtVolumeHistogram* histogram;
histogram = new QtVolumeHistogram( 0, (const char*) "QtVolumeHistogram" );
histogram->SetVolumeSource( &vol );
histogram->SetNumberOfBins( 255 );
histogram->SetMinIgnore( 0 );
histogram->SetMaxIgnore( 20 );
histogram->SetNumberOfMarkers( 4 );
histogram->SetMarkerColor( 0, Qt::red );
histogram->SetMarkerValue( 0, 10 );
histogram->SetMarkerColor( 1, Qt::green );
histogram->SetMarkerValue( 1, 30 );
histogram->SetMarkerColor( 2, Qt::blue );
histogram->SetMarkerValue( 2, 50 );
histogram->SetMarkerColor( 3, Qt::yellow );
histogram->SetMarkerValue( 3, 70 );
histogram->resize( 600, 200 );
a.setMainWidget( histogram );
histogram->show();
QApplication::setGlobalMouseTracking( true );
return a.exec();
} catch ( runtime_error& e ) {
cerr << "failed with exception: " << e.what() << endl;
exit( 1 );
} catch ( exception& e ) {
cerr << "failed with exception: " << e.what() << endl;
exit( 1 );
} catch (...) {
cerr << "failed" << endl;
exit( 1 );
}
exit( 0 );
}
示例2: runtime_error
void
SegmentationVolumeReportTester::Test ( Tcl_Interp* iInterp ) {
try {
// Load our seg volume.
string fnSegVolume = "test_data/testSegmentationVolumeReportData-Seg.mgz";
VolumeCollection seg;
seg.SetFileName( fnSegVolume );
seg.LoadVolume();
seg.SetLabel( "Seg" );
// Load our intensity volume.
string fnIntVolume = "test_data/testSegmentationVolumeReportData-Int.mgz";
VolumeCollection vol;
vol.SetFileName( fnIntVolume );
vol.LoadVolume();
vol.SetLabel( "Int" );
// Load our LUT.
string fnLUT = "test_data/TestLUT.txt";
ScubaColorLUT lut;
lut.UseFile( fnLUT );
// Set up the report.
SegmentationVolumeReport& report =
SegmentationVolumeReport::GetReport();
report.SetSegmentation( seg );
if ( NULL == report.mSegVol ) {
stringstream ssError;
ssError << "Error on SetSegmentation, mSegVol was NULL";
throw runtime_error( ssError.str() );
}
if ( report.mSegVol->GetID() != seg.GetID() ) {
stringstream ssError;
ssError << "Error on SetSegmentation, mSegVol was the wrong volume (should be ID " << seg.GetID() << " but was " << report.mSegVol->GetID();
throw runtime_error( ssError.str() );
}
report.DontUseROI();
if ( report.mbUseROI ) {
stringstream ssError;
ssError << "Error on DontUseROI, mbUseROI was true";
throw runtime_error( ssError.str() );
}
report.SetColorLUT( lut );
if ( NULL == report.mLUT ) {
stringstream ssError;
ssError << "Error on SetColorLUT, mROI was NULL";
throw runtime_error( ssError.str() );
}
if ( report.mLUT->GetID() != lut.GetID() ) {
stringstream ssError;
ssError << "Error on SetColorLUT, id didn't match";
throw runtime_error( ssError.str() );
}
// Add 1-5 but not 3.
report.AddSegmentationStructure( 1 );
report.AddSegmentationStructure( 2 );
report.AddSegmentationStructure( 4 );
report.AddSegmentationStructure( 5 );
map<int,bool> structureMap;
list<int>::iterator tStructure;
for ( tStructure = report.mlStructures.begin();
tStructure != report.mlStructures.end(); ++tStructure ) {
int nStructure = *tStructure;
if ( nStructure != 1 && nStructure != 2 &&
nStructure != 4 && nStructure != 5 ) {
stringstream ssError;
ssError << "Error on AddSegmentationStructure, added an unknown structure " << nStructure;
throw runtime_error( ssError.str() );
}
structureMap[nStructure] = true;
}
if ( !(structureMap[1] && structureMap[2] &&
structureMap[4] && structureMap[5]) ) {
stringstream ssError;
ssError << "Error in AddSegmentationStructure, didn't add all structures";
throw runtime_error( ssError.str() );
}
// Test handling of undefined structures.
report.AddSegmentationStructure( 200 );
// Add the intensity volume. Also add the seg vol as an additional
// intensity volume.
report.AddIntensityVolume( vol );
report.AddIntensityVolume( seg );
map<int,bool> volsLoadedMap;
list<VolumeCollection*>::iterator tVolume;
for ( tVolume = report.mlIntVols.begin();
tVolume != report.mlIntVols.end(); ++tVolume ) {
VolumeCollection* testVol = *tVolume;
int volID = testVol->GetID();
//.........这里部分代码省略.........
示例3: fnSave
void
VolumeCollectionTester::Test ( Tcl_Interp* iInterp ) {
stringstream ssError;
try {
string fnMRI = "test_data/bertT1.mgz";
VolumeCollection* vol = new VolumeCollection();
vol->SetFileName( fnMRI );
MRI* mri = const_cast<MRI*>(vol->GetMRI());
Assert( (vol->GetTypeDescription() == "Volume"),
"GetTypeDescription didn't return Volume" );
DataManager dataMgr = DataManager::GetManager();
MRILoader mriLoader = dataMgr.GetMRILoader();
Assert( 1 == mriLoader.CountLoaded(),
"CountLoaded didn't return 1" );
Assert( 1 == mriLoader.CountReferences(mri),
"CountReferences didn't return 1" );
char* fnMRIC = strdup( fnMRI.c_str() );
MRI* mriComp = MRIread( fnMRIC );
Assert( (MRImatch( mriComp, mri )), "MRImatch failed for load" );
MRIfree( &mriComp );
// Save it in /tmp, load it, and match it again.
string fnSave( "/tmp/test.mgz" );
vol->Save( fnSave );
VolumeCollection* testVol = new VolumeCollection();
testVol->SetFileName( fnSave );
MRI* testMri = const_cast<MRI*>(testVol->GetMRI());
Assert( (MRImatch( testMri, mri )), "MRImatch failed for load after save");
// Make an ROI and make sure it's a volume ROI.
try {
int roiID = vol->NewROI();
ScubaROIVolume* roi =
dynamic_cast<ScubaROIVolume*>(&ScubaROI::FindByID( roiID ));
roi = NULL;
} catch (...) {
throw( runtime_error("typecast failed for NewROI") );
}
// Try our conversions.
Point3<float> world;
Point3<float> data;
Point3<int> index;
world.Set( -50, 0, -80 );
vol->RASToMRIIndex( world.xyz(), index.xyz() );
{
stringstream ssError;
ssError << "RASToMRIIndex failed. world "
<< world << " index " << index;
Assert( (index.x() == 178 && index.y() == 208 && index.z() == 128),
ssError.str() );
}
// Set a transform that scales the volume up by 2x in the world.
ScubaTransform dataTransform;
dataTransform.SetMainTransform( 2, 0, 0, 0,
0, 2, 0, 0,
0, 0, 2, 0,
0, 0, 0, 1 );
vol->SetDataToWorldTransform( dataTransform.GetID() );
world.Set( -50, 0, -80 );
vol->RASToDataRAS( world.xyz(), data.xyz() );
{
stringstream ssError;
ssError << "RASToDataRAS failed. world "
<< world << " data " << data;
Assert( ((FEQUAL(data.x(),-25)) &&
(FEQUAL(data.y(),0)) &&
(FEQUAL(data.z(),-40))),
ssError.str() );
}
vol->RASToMRIIndex( world.xyz(), index.xyz() );
if ( index.x() != 153 || index.y() != 168 || index.z() != 128 ) {
cerr << "RASToMRIIndex with data transform failed. world "
<< world << " index " << index << endl;
throw( runtime_error( "failed" ) );
}
world.Set( -50, 0, -80 );
VolumeLocation loc( vol->MakeVolumeLocationFromRAS( world.xyz() ) );
if ( !vol->IsInBounds( loc ) ) {
stringstream ssError;
ssError << "IsInBounds failed. world " << world;
//.........这里部分代码省略.........