bool SelectionVOI::populateXMLNode( wxXmlNode *pCurNode, const wxString &rootPath ) { bool result( SelectionObject::populateXMLNode( pCurNode, rootPath ) ); if( result ) { wxString floatPrecision = wxT( ".8" ); wxXmlNode *pVoiNode = new wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT( "voi_properties" ) ); pCurNode->AddChild( pVoiNode ); pVoiNode->AddAttribute( new wxXmlAttribute( wxT( "gen_threshold" ), wxStrFormat( m_generationThreshold, floatPrecision ) ) ); pVoiNode->AddAttribute( new wxXmlAttribute( wxT( "thres_op_type" ), Helper::getThresholdingTypeString( m_thresType ) ) ); wxXmlNode *pVoiGenAnatPath = new wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT( "generation_anatomy" ) ); pVoiNode->AddChild( pVoiGenAnatPath ); // Get the dataset to be able to get the index. DatasetInfo *pDS = DatasetManager::getInstance()->getDataset( m_sourceAnatIndex ); if( pDS ) { wxFileName tempName( pDS->getPath() ); tempName.MakeRelativeTo( rootPath ); pVoiGenAnatPath->AddChild( new wxXmlNode( NULL, wxXML_TEXT_NODE, wxT( "path"), tempName.GetFullPath() ) ); } else { // Should never happen. result = false; } } return result; }
void DatasetManager::remove( const DatasetIndex index ) { map<DatasetIndex, DatasetInfo *>::iterator it = m_datasets.find( index ); DatasetInfo *pDatasetInfo = it->second; switch( pDatasetInfo->getType() ) { case HEAD_BYTE: case HEAD_SHORT: case OVERLAY: case RGB: Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), static_cast<unsigned int>( index ), wxT( "Anatomy" ) ), LOGLEVEL_DEBUG ); m_anatomies.erase( m_anatomies.find( index ) ); break; // case TENSOR_FIELD: // break; case MESH: Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), static_cast<unsigned int>( index ), wxT( "Mesh" ) ), LOGLEVEL_DEBUG ); m_meshes.erase( m_meshes.find( index ) ); break; // case VECTORS: // break; case TENSORS: Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), static_cast<unsigned int>( index ), wxT( "Tensors" ) ), LOGLEVEL_DEBUG ); m_tensors.erase( m_tensors.find( index ) ); break; case ODFS: Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), static_cast<unsigned int>( index ), wxT( "ODFs" ) ), LOGLEVEL_DEBUG ); m_odfs.erase( m_odfs.find( index ) ); break; case FIBERS: Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), static_cast<unsigned int>( index ), wxT( "Fibers" ) ), LOGLEVEL_DEBUG ); m_fibers.erase( m_fibers.find( index ) ); break; // case SURFACE: // Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), index, wxT( "Surface" ) ), LOGLEVEL_DEBUG ); // m_surfaces.erase( m_surfaces.find( index ) ); // break; // case ISO_SURFACE: // break; case FIBERSGROUP: Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), static_cast<unsigned int>( index ), wxT( "FibersGroup" ) ), LOGLEVEL_DEBUG ); m_fibersGroup.erase( m_fibersGroup.find( index ) ); break; case MAXIMAS: Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), static_cast<unsigned int>( index ), wxT( "Maximas" ) ), LOGLEVEL_DEBUG ); m_maximas.erase( m_maximas.find( index ) ); break; default: Logger::getInstance()->print( wxString::Format( wxT( "Removing index: %u type: %s" ), static_cast<unsigned int>( index ), wxT( "DatasetInfo" ) ), LOGLEVEL_DEBUG ); break; } m_datasets.erase( index ); m_reverseDatasets.erase( pDatasetInfo ); delete pDatasetInfo; }
void ToolBar::updateToolBar( MainFrame *mf ) { ToggleTool( m_toggleShowAxial->GetId(), SceneManager::getInstance()->isAxialDisplayed() ); ToggleTool( m_toggleShowCoronal->GetId(), SceneManager::getInstance()->isCoronalDisplayed() ); ToggleTool( m_toggleShowSagittal->GetId(), SceneManager::getInstance()->isSagittalDisplayed() ); ToggleTool( m_toggleAlphaBlending->GetId(), SceneManager::getInstance()->isAlphaBlend() ); ToggleTool( m_toggleLighting->GetId(), SceneManager::getInstance()->isLightingActive() ); ToggleTool( m_toggleShowAllSelectionObjects->GetId(), SceneManager::getInstance()->getShowAllSelObj() ); ToggleTool( m_toggleActivateAllSelectionObjects->GetId(), !SceneManager::getInstance()->getActivateAllSelObj() ); bool isFiberSelected = false; bool isFiberUsingFakeTubes = false; bool isFiberInverted = false; if (mf->m_pCurrentSceneObject != NULL && mf->m_currentListIndex != -1) { DatasetInfo* pDatasetInfo = ((DatasetInfo*)mf->m_pCurrentSceneObject); if( pDatasetInfo->getType() == FIBERS || pDatasetInfo->getType() == FIBERSGROUP ) { isFiberSelected = true; Fibers* pFibers = (Fibers*)pDatasetInfo; if( pFibers ) { isFiberUsingFakeTubes = pFibers->isUsingFakeTubes(); isFiberInverted = pFibers->isFibersInverted(); } } } ToggleTool( m_toggleFakeTubes->GetId(), isFiberSelected && isFiberUsingFakeTubes); ToggleTool( m_toggleInverseSelection->GetId(), isFiberSelected && isFiberInverted); ToggleTool( m_toggleClearToBlack->GetId(), SceneManager::getInstance()->getClearToBlack() ); ToggleTool( m_selectNormalPointer->GetId(), SceneManager::getInstance()->isRulerActive() && mf->isDrawerToolActive() ); ToggleTool( m_selectRuler->GetId(), SceneManager::getInstance()->isRulerActive() ); ToggleTool( m_selectDrawer->GetId(), mf->isDrawerToolActive() ); //SetToolNormalBitmap(m_selectColorPicker->GetId(), wxBitmap(mf->m_pDatasetHelper->m_drawColorIcon)); ToggleTool( m_toggleDrawRound->GetId(), mf->canDrawRound() ); ToggleTool( m_toggleDraw3d->GetId(), mf->canDraw3D() ); ToggleTool( m_selectPen->GetId(), DRAWMODE_PEN == mf->getDrawMode() ); ToggleTool( m_selectEraser->GetId(), DRAWMODE_ERASER == mf->getDrawMode() ); // Check if the currently selected anatomy can use the Color Picker. EnableTool( m_selectColorPicker->GetId(), DRAWMODE_PEN == mf->getDrawMode() && mf->canUseColorPicker() ); }
void MenuBar::updateMenuBar( MainFrame *mf ) { m_itemToggleLighting->Check( SceneManager::getInstance()->isLightingActive() ); #if !_USE_LIGHT_GUI m_itemToggleRuler->Check( SceneManager::getInstance()->isRulerActive() ); #endif bool isFiberSelected( false ); bool isFiberUsingFakeTubes( false ); bool isFiberUsingTransparency( false ); bool isFiberInverted( false ); if (mf->m_pCurrentSceneObject != NULL && mf->m_currentListIndex != -1) { DatasetInfo* pDatasetInfo = ((DatasetInfo*)mf->m_pCurrentSceneObject); if( pDatasetInfo->getType() == FIBERS ) { isFiberSelected = true; Fibers* pFibers = (Fibers*)pDatasetInfo; if( pFibers ) { isFiberUsingFakeTubes = pFibers->isUsingFakeTubes(); isFiberUsingTransparency = pFibers->isUsingTransparency(); isFiberInverted = pFibers->isFibersInverted(); } } else if( pDatasetInfo->getType() == FIBERSGROUP ) { isFiberSelected = true; FibersGroup* pFibersGroup = (FibersGroup*)pDatasetInfo; if( pFibersGroup ) { unsigned int useFakeTubesNb = 0; unsigned int useTransparencyNb = 0; unsigned int isInvertedNb = 0; vector<Fibers *> v = DatasetManager::getInstance()->getFibers(); for(vector<Fibers *>::const_iterator it = v.begin(); it != v.end(); ++it ) { if( (*it)->isUsingFakeTubes()) ++useFakeTubesNb; if( (*it)->isUsingTransparency() ) ++useTransparencyNb; if( (*it)->isFibersInverted() ) ++isInvertedNb; } isFiberUsingFakeTubes = ( useFakeTubesNb == v.size() ); isFiberUsingTransparency = ( useTransparencyNb == v.size() ); isFiberInverted = ( isInvertedNb == v.size() ); } } } m_itemSaveSelectedFibers->Enable(isFiberSelected); #if !_USE_LIGHT_GUI m_itemResetFibersColors->Enable(isFiberSelected); m_itemToggleInvertFibersSelection->Enable(isFiberSelected); m_itemToggleInvertFibersSelection->Check(isFiberInverted); m_itemToggleUseTransparency->Enable(isFiberSelected); m_itemToggleUseTransparency->Check(isFiberUsingTransparency); m_itemToggleUseFakeTubes->Enable(isFiberSelected); m_itemToggleUseFakeTubes->Check(isFiberUsingFakeTubes); m_itemToggleUseGeometryShader->Check( SceneManager::getInstance()->isFibersGeomShaderActive() ); #if _COMPILE_GEO_SHADERS m_itemToggleUseGeometryShader->Enable( SceneManager::getInstance()->areGeometryShadersSupported() ); #else m_itemToggleUseGeometryShader->Enable(false); #endif // _COMPILE_GEO_SHADERS #endif // !_USE_LIGHT_GUI m_itemToggleShowAxial->Check( SceneManager::getInstance()->isAxialDisplayed() ); m_itemToggleShowCoronal->Check( SceneManager::getInstance()->isCoronalDisplayed() ); m_itemToggleShowSagittal->Check( SceneManager::getInstance()->isSagittalDisplayed() ); m_itemToggleClearToBlack->Check( SceneManager::getInstance()->getClearToBlack() ); m_itemToggleBlendTextureOnMesh->Check( SceneManager::getInstance()->isTexBlendOnMesh() ); m_itemToggleFilterISO->Check( SceneManager::getInstance()->isIsoSurfaceFiltered() ); #if !_USE_LIGHT_GUI m_itemToggleShowCrosshair->Check( SceneManager::getInstance()->isCrosshairDisplayed() ); m_itemToggleShowAxes->Check( SceneManager::getInstance()->areAxesDisplayed() ); m_itemToggleShowColorBar->Check( SceneManager::getInstance()->isColorbarDisplayed() ); m_itemToggleDrawPoints->Check( SceneManager::getInstance()->isPointMode() ); m_itemToggleDrawVectors->Check( SceneManager::getInstance()->areVectorsDisplayed() ); #endif m_itemToggleDrawer->Check( mf->isDrawerToolActive() ); m_itemToggleDrawRound->Check( mf->canDrawRound() ); m_itemToggleDraw3d->Check( mf->canDraw3D() ); m_itemDrawPen->Check( DRAWMODE_PEN == mf->getDrawMode() ); m_itemDrawEraser->Check( DRAWMODE_ERASER == mf->getDrawMode() ); m_itemToggleDrawRound->Enable( mf->isDrawerToolActive() ); m_itemToggleDraw3d->Enable( mf->isDrawerToolActive() ); m_itemDrawPen->Enable( mf->isDrawerToolActive() ); m_itemDrawEraser->Enable( mf->isDrawerToolActive() ); m_itemDrawColorPicker->Enable( mf->isDrawerToolActive() && mf->canUseColorPicker() && DRAWMODE_PEN == mf->getDrawMode() ); }
int main(int argc, char** argv) { CLI::ParseCommandLine(argc, argv); // Check input parameters for validity. const string numericSplitStrategy = CLI::GetParam<string>("numeric_split_strategy"); if ((CLI::HasParam("predictions") || CLI::HasParam("probabilities")) && !CLI::HasParam("test")) Log::Fatal << "--test_file must be specified if --predictions_file or " << "--probabilities_file is specified." << endl; if (!CLI::HasParam("training") && !CLI::HasParam("input_model")) Log::Fatal << "One of --training_file or --input_model_file must be " << "specified!" << endl; if (CLI::HasParam("training") && !CLI::HasParam("labels")) Log::Fatal << "If --training_file is specified, --labels_file must be " << "specified too!" << endl; if (!CLI::HasParam("training") && CLI::HasParam("batch_mode")) Log::Warn << "--batch_mode (-b) ignored; no training set provided." << endl; if (CLI::HasParam("passes") && CLI::HasParam("batch_mode")) Log::Warn << "--batch_mode (-b) ignored because --passes was specified." << endl; if (CLI::HasParam("test") && !CLI::HasParam("predictions") && !CLI::HasParam("probabilities") && !CLI::HasParam("test_labels")) Log::Warn << "--test_file (-T) is specified, but none of " << "--predictions_file (-p), --probabilities_file (-P), or " << "--test_labels_file (-L) are specified, so no output will be given!" << endl; if ((numericSplitStrategy != "domingos") && (numericSplitStrategy != "binary")) { Log::Fatal << "Unrecognized numeric split strategy (" << numericSplitStrategy << ")! Must be 'domingos' or 'binary'." << endl; } // Do we need to load a model or do we already have one? HoeffdingTreeModel model; DatasetInfo datasetInfo; arma::mat trainingSet; arma::Mat<size_t> labels; if (CLI::HasParam("input_model")) { model = std::move(CLI::GetParam<HoeffdingTreeModel>("input_model")); } else { // Initialize a model. if (!CLI::HasParam("info_gain") && (numericSplitStrategy == "domingos")) model = HoeffdingTreeModel(HoeffdingTreeModel::GINI_HOEFFDING); else if (!CLI::HasParam("info_gain") && (numericSplitStrategy == "binary")) model = HoeffdingTreeModel(HoeffdingTreeModel::GINI_BINARY); else if (CLI::HasParam("info_gain") && (numericSplitStrategy == "domingos")) model = HoeffdingTreeModel(HoeffdingTreeModel::INFO_HOEFFDING); else if (CLI::HasParam("info_gain") && (numericSplitStrategy == "binary")) model = HoeffdingTreeModel(HoeffdingTreeModel::INFO_BINARY); } // Now, do we need to train? if (CLI::HasParam("training")) { // Load necessary parameters for training. const double confidence = CLI::GetParam<double>("confidence"); const size_t maxSamples = (size_t) CLI::GetParam<int>("max_samples"); const size_t minSamples = (size_t) CLI::GetParam<int>("min_samples"); bool batchTraining = CLI::HasParam("batch_mode"); const size_t bins = (size_t) CLI::GetParam<int>("bins"); const size_t observationsBeforeBinning = (size_t) CLI::GetParam<int>("observations_before_binning"); size_t passes = (size_t) CLI::GetParam<int>("passes"); if (passes > 1) batchTraining = false; // We already warned about this earlier. // We need to train the model. First, load the data. datasetInfo = std::move(std::get<0>(CLI::GetParam<TupleType>("training"))); trainingSet = std::move(std::get<1>(CLI::GetParam<TupleType>("training"))); for (size_t i = 0; i < trainingSet.n_rows; ++i) Log::Info << datasetInfo.NumMappings(i) << " mappings in dimension " << i << "." << endl; labels = CLI::GetParam<arma::Mat<size_t>>("labels"); if (labels.n_rows > 1) labels = labels.t(); if (labels.n_rows > 1) Log::Fatal << "Labels must be one-dimensional!" << endl; // Next, create the model with the right type. Then build the tree with the // appropriate type of instantiated numeric split type. This is a little // bit ugly. Maybe there is a nicer way to get this numeric split // information to the trees, but this is ok for now. Timer::Start("tree_training"); // Do we need to initialize a model? if (!CLI::HasParam("input_model")) { // Build the model. model.BuildModel(trainingSet, datasetInfo, labels.row(0), arma::max(labels.row(0)) + 1, batchTraining, confidence, maxSamples, 100, minSamples, bins, observationsBeforeBinning); --passes; // This model-building takes one pass. } // Now pass over the trees as many times as we need to. if (batchTraining) { // We only need to do batch training if we've not already called // BuildModel. if (CLI::HasParam("input_model")) model.Train(trainingSet, labels.row(0), true); } else { for (size_t p = 0; p < passes; ++p) model.Train(trainingSet, labels.row(0), false); } Timer::Stop("tree_training"); } // Do we need to evaluate the training set error? if (CLI::HasParam("training")) { // Get training error. arma::Row<size_t> predictions; model.Classify(trainingSet, predictions); size_t correct = 0; for (size_t i = 0; i < labels.n_elem; ++i) if (labels[i] == predictions[i]) ++correct; Log::Info << correct << " out of " << labels.n_elem << " correct " << "on training set (" << double(correct) / double(labels.n_elem) * 100.0 << ")." << endl; } // Get the number of nodes in the tree. Log::Info << model.NumNodes() << " nodes in the tree." << endl; // The tree is trained or loaded. Now do any testing if we need. if (CLI::HasParam("test")) { // Before loading, pre-set the dataset info by getting the raw parameter // (that doesn't call data::Load()). std::get<0>(CLI::GetRawParam<TupleType>("test")) = datasetInfo; arma::mat testSet = std::get<1>(CLI::GetParam<TupleType>("test")); arma::Row<size_t> predictions; arma::rowvec probabilities; Timer::Start("tree_testing"); model.Classify(testSet, predictions, probabilities); Timer::Stop("tree_testing"); if (CLI::HasParam("test_labels")) { arma::Mat<size_t> testLabels = std::move(CLI::GetParam<arma::Mat<size_t>>("test_labels")); if (testLabels.n_rows > 1) testLabels = testLabels.t(); if (testLabels.n_rows > 1) Log::Fatal << "Test labels must be one-dimensional!" << endl; size_t correct = 0; for (size_t i = 0; i < testLabels.n_elem; ++i) { if (predictions[i] == testLabels[i]) ++correct; } Log::Info << correct << " out of " << testLabels.n_elem << " correct " << "on test set (" << double(correct) / double(testLabels.n_elem) * 100.0 << ")." << endl; } if (CLI::HasParam("predictions")) CLI::GetParam<arma::Mat<size_t>>("predictions") = std::move(predictions); if (CLI::HasParam("probabilities")) CLI::GetParam<arma::mat>("probabilities") = std::move(probabilities); } // Check the accuracy on the training set. if (CLI::HasParam("output_model")) CLI::GetParam<HoeffdingTreeModel>("output_model") = std::move(model); CLI::Destroy(); }
bool Load(const std::string& filename, arma::Mat<eT>& matrix, DatasetInfo& info, const bool fatal, const bool transpose) { // Get the extension and load as necessary. Timer::Start("loading_data"); // Get the extension. std::string extension = Extension(filename); // Catch nonexistent files by opening the stream ourselves. std::fstream stream; stream.open(filename.c_str(), std::fstream::in); if (!stream.is_open()) { Timer::Stop("loading_data"); if (fatal) Log::Fatal << "Cannot open file '" << filename << "'. " << std::endl; else Log::Warn << "Cannot open file '" << filename << "'; load failed." << std::endl; return false; } if (extension == "csv" || extension == "tsv" || extension == "txt") { // True if we're looking for commas; if false, we're looking for spaces. bool commas = (extension == "csv"); std::string type; if (extension == "csv") type = "CSV data"; else type = "raw ASCII-formatted data"; Log::Info << "Loading '" << filename << "' as " << type << ". " << std::flush; std::string separators; if (commas) separators = ","; else separators = " \t"; // We'll load this as CSV (or CSV with spaces or tabs) according to // RFC4180. So the first thing to do is determine the size of the matrix. std::string buffer; size_t cols = 0; std::getline(stream, buffer, '\n'); // Count commas and whitespace in the line, ignoring anything inside // quotes. typedef boost::tokenizer<boost::escaped_list_separator<char>> Tokenizer; boost::escaped_list_separator<char> sep("\\", separators, "\""); Tokenizer tok(buffer, sep); for (Tokenizer::iterator i = tok.begin(); i != tok.end(); ++i) ++cols; // Now count the number of lines in the file. We've already counted the // first one. size_t rows = 1; while (!stream.eof() && !stream.bad() && !stream.fail()) { std::getline(stream, buffer, '\n'); if (!stream.fail()) ++rows; } // Now we have the size. So resize our matrix. if (transpose) { matrix.set_size(cols, rows); info = DatasetInfo(cols); } else { matrix.set_size(rows, cols); info = DatasetInfo(rows); } stream.close(); stream.open(filename, std::fstream::in); // Extract line by line. std::stringstream token; size_t row = 0; while (!stream.bad() && !stream.fail() && !stream.eof()) { std::getline(stream, buffer, '\n'); // Look at each token. Unfortunately we have to do this character by // character, because things may be escaped in quotes. Tokenizer lineTok(buffer, sep); size_t col = 0; for (Tokenizer::iterator it = lineTok.begin(); it != lineTok.end(); ++it) { // Attempt to extract as type eT. If that fails, we'll assume it's a // string and map it (which may involve retroactively mapping everything // we've seen so far). token.clear(); token.str(*it); eT val = eT(0); token >> val; if (token.fail()) { // Conversion failed; but it may be a NaN or inf. Armadillo has // convenient functions to check. if (!arma::diskio::convert_naninf(val, token.str())) { // We need to perform a mapping. const size_t dim = (transpose) ? col : row; if (info.Type(dim) == Datatype::numeric) { // We must map everything we have seen up to this point and change // the values in the matrix. if (transpose) { // Whatever we've seen so far has successfully mapped to an eT. // So we need to print it back to a string. We'll use // Armadillo's functionality for that. for (size_t i = 0; i < row; ++i) { std::stringstream sstr; arma::arma_ostream::print_elem(sstr, matrix.at(i, col), false); eT newVal = info.MapString(sstr.str(), col); matrix.at(i, col) = newVal; } } else { for (size_t i = 0; i < col; ++i) { std::stringstream sstr; arma::arma_ostream::print_elem(sstr, matrix.at(row, i), false); eT newVal = info.MapString(sstr.str(), row); matrix.at(row, i) = newVal; } } } // Strip whitespace from either side of the string. std::string trimmedToken(token.str()); boost::trim(trimmedToken); val = info.MapString(trimmedToken, dim); } } if (transpose) matrix(col, row) = val; else matrix(row, col) = val; ++col; } ++row; } }
void LSMReader::Preprocess() { FILE* pfile = 0; if (!WFOPEN(&pfile, m_path_name.c_str(), L"rb")) return; m_lsm_info.clear(); m_l4gb = false; int i, j; unsigned int ioffset = 0; fread(&ioffset, sizeof(unsigned int), 1, pfile); if (ioffset!=0x002A4949) { fclose(pfile); return; } int cnt_image = 0; bool full_image = false; //first offset if (fread(&ioffset, sizeof(unsigned int), 1, pfile)<1) { fclose(pfile); return; } unsigned int prev_offset = 0; unsigned int offset_high = 0; //images while (fseek(pfile, ioffset, SEEK_SET)==0) { unsigned short entry_num; //entry number if (fread(&entry_num, sizeof(unsigned short), 1, pfile)<1) { fclose(pfile); return; } vector<unsigned int> offsets; vector<unsigned int> offset_highs; vector<unsigned int> sizes; for (i=0; i<entry_num; i++) { unsigned short tag; if (fread(&tag, sizeof(unsigned short), 1, pfile)<1) { fclose(pfile); return; } unsigned short type; if (fread(&type, sizeof(unsigned short), 1, pfile)<1) { fclose(pfile); return; } unsigned int length; if (fread(&length, sizeof(unsigned int), 1, pfile)<1) { fclose(pfile); return; } unsigned int value; if (fread(&value, sizeof(unsigned int), 1, pfile)<1) { fclose(pfile); return; } //remember current position long cur_pos = ftell(pfile); switch (tag) { case 0x00FE://254, new subfile type if (value==0) { full_image = true; cnt_image++; } else full_image = false; break; case 0x0100://256, image width if (full_image && cnt_image == 1) m_x_size = value; break; case 0x0101://257, image length if (full_image && cnt_image == 1) m_y_size = value; break; case 0x0102://258, bits per sample break; case 0x0103://259, compression if (full_image && cnt_image == 1) m_compression = value<<16>>16; break; case 0x0106://262, photometric interpretation break; case 0x0111://273, strip offsets if (full_image) { if (length==1) { offsets.push_back(value); if (value < prev_offset) { m_l4gb = true; offset_high++; } prev_offset = value; offset_highs.push_back(offset_high); } else { if (fseek(pfile, value, SEEK_SET)==0) { unsigned int vtemp; for (j=0; j<(int)length; j++) { if (fread(&vtemp, sizeof(unsigned int), 1, pfile)==1) { offsets.push_back(vtemp); if (vtemp < prev_offset) { m_l4gb = true; offset_high++; } prev_offset = vtemp; offset_highs.push_back(offset_high); } } } } } break; case 0x0115://277, samples per pixel if (full_image && cnt_image == 1) m_chan_num = value<<16>>16; break; case 0x0117://279, strip byte counts if (full_image) { if (length==1) { sizes.push_back(value); } else { if (fseek(pfile, value, SEEK_SET)==0) { unsigned int vtemp; for (j=0; j<(int)length; j++) { if (fread(&vtemp, sizeof(unsigned int), 1, pfile)==1) sizes.push_back(vtemp); } } } } break; case 0x011C://284, planar configuration break; case 0x013D://317, predictor if (full_image && cnt_image == 1) m_predictor = value<<16>>16; break; break; case 0x0140://320, colormap break; case 0x866C://34412, zeiss lsm info if (type == 1) { if (fseek(pfile, value, SEEK_SET)!=0) { fclose(pfile); return; } unsigned char* pdata = new unsigned char[length]; if (fread(pdata, sizeof(unsigned char), length, pfile)!=length) { fclose(pfile); return; } //read lsm info ReadLsmInfo(pfile, pdata, length); //delete delete []pdata; } break; } //reset position if (fseek(pfile, cur_pos, SEEK_SET)!=0) { fclose(pfile); return; } } //build lsm info, which contains all offset values and sizes if (full_image) { int time = (cnt_image-1) / m_slice_num; if (time+1 > (int)m_lsm_info.size()) { DatasetInfo dinfo; for (i=0; i<m_chan_num; i++) { ChannelInfo cinfo; dinfo.push_back(cinfo); } m_lsm_info.push_back(dinfo); } //int slice = (cnt_image-1) % m_slice_num; for (i=0; i<m_chan_num; i++) { SliceInfo sinfo; sinfo.offset = offsets[i]; sinfo.offset_high = offset_highs[i]; sinfo.size = sizes[i]; //add slice info to lsm info m_lsm_info[time][i].push_back(sinfo); } } //next image if (fread(&ioffset, sizeof(unsigned int), 1, pfile)<1) { fclose(pfile); return; } if (!ioffset) break; } fclose(pfile); m_cur_time = 0; m_data_name = m_path_name.substr(m_path_name.find_last_of(GETSLASH())+1); }