void OIFReader::ReadSingleOif()
{
   m_subdir_name = m_path_name + L".files" + GETSLASH();
   std::vector<std::wstring> list;
   int tmp;
   FIND_FILES(m_subdir_name,L".tif",list,tmp);
   //read file sequence
   for(size_t f = 0; f < list.size(); f++)
      ReadTifSequence(list.at(f));
}
Exemple #2
0
void LSMReader::SetBatch(bool batch)
{
    if (batch)
    {
        //read the directory info
        FIND_FILES(m_path_name,L".lsm",m_batch_list,m_cur_batch);
        m_batch = true;
    }
    else
        m_batch = false;
}
void OIFReader::SetBatch(bool batch)
{
   if (batch)
   {
      //read the directory info
      wstring search_path = m_path_name.substr(0, m_path_name.find_last_of(GETSLASH())) + GETSLASH();
      FIND_FILES(search_path,L".oif",m_batch_list,m_cur_batch);
      m_batch = true;
   }
   else
      m_batch = false;
}
void OIFReader::ReadSequenceOif()
{
   for (int i=0; i<(int)m_oif_info.size(); i++)
   {
      wstring path_name = m_oif_info[i].filename;
      m_oif_info[i].subdirname = path_name + L".files" + GETSLASH();

      if (path_name == m_path_name)
         m_cur_time = i;

      m_subdir_name = path_name + L".files" + GETSLASH();
      std::vector<std::wstring> list;
      FIND_FILES(m_subdir_name,L".tif",list,m_oif_t);
      //read file sequence
      for(size_t f = 0; f < list.size(); f++)
         ReadTifSequence(list.at(f), i);
   }
}
void OIFReader::Preprocess()
{
   m_type = 0;
   m_oif_info.clear();

   //separate path and name
   int64_t pos = m_path_name.find_last_of(GETSLASH());
   if (pos == -1)
      return;
   wstring path = m_path_name.substr(0, pos+1);
   wstring name = m_path_name.substr(pos+1);
   //extract time sequence string
   int64_t begin = name.find(m_time_id);
   size_t end = -1;
   size_t id_len = m_time_id.size();
   if (begin != -1)
   {
      wstring t_num;
      size_t j;
      for (j=begin+id_len; j<name.size(); j++)
      {
         wchar_t c = name[j];
         if (iswdigit(c))
            t_num.push_back(c);
         else break;
      }
      if (t_num.size() > 0)
         end = j;
      else
         begin = -1;
   }

   if (begin == -1)
   {
      ReadSingleOif();
   }
   else
   {
      //search time sequence files
      std::vector<std::wstring> list;
      int tmp = 0;
      FIND_FILES(path,L".oif",list,tmp,name.substr(0,begin+id_len+1));
      for(size_t i = 0; i < list.size(); i++) {
         size_t start_idx = list.at(i).find(m_time_id) + id_len;
         size_t end_idx   = list.at(i).find(L".oif");
         size_t size = end_idx - start_idx;
         std::wstring fileno = list.at(i).substr(start_idx, size);
         TimeDataInfo info;
         info.filenumber = WSTOI(fileno);
         info.filename = list.at(i);
         m_oif_info.push_back(info);
      }

      if (m_oif_info.size() > 0)
      {
         m_type = 1;
         std::sort(m_oif_info.begin(), m_oif_info.end(), OIFReader::oif_sort);
         ReadSequenceOif();
      }
      else
      {
         m_oif_info.clear();
         ReadSingleOif();
      }
   }

   ReadOif();

   m_time_num = int(m_oif_info.size());
   if (m_type == 0)
      m_cur_time = 0;
   m_chan_num = m_time_num>0?int(m_oif_info[0].dataset.size()):0;
   m_slice_num = m_chan_num>0?int(m_oif_info[0].dataset[0].size()):0;
}
Exemple #6
0
void NRRDReader::Preprocess()
{
   m_4d_seq.clear();

   //separate path and name
   int64_t pos = m_path_name.find_last_of(GETSLASH());
   if (pos == -1)
      return;
   wstring path = m_path_name.substr(0, pos+1);
   wstring name = m_path_name.substr(pos+1);
   //generate search name for time sequence
   int64_t begin = name.find(m_time_id);
   size_t end = -1;
   size_t id_len = m_time_id.size();
   wstring t_num;
   if (begin != -1)
   {
      size_t j;
      for (j=begin+id_len; j<name.size(); j++)
      {
         wchar_t c = name[j];
         if (iswdigit(c))
            t_num.push_back(c);
         else
            break;
      }
      if (t_num.size() > 0)
         end = j;
      else
         begin = -1;
   }
   //build 4d sequence
   if (begin == -1)
   {
      TimeDataInfo info;
      info.filenumber = 0;
      info.filename = m_path_name;
      m_4d_seq.push_back(info);
      m_cur_time = 0;
   }
   else
   {
      //search time sequence files
      std::vector<std::wstring> list;
      int tmp = 0;
      FIND_FILES(path,L".nrrd",list,tmp,name.substr(0,begin+id_len+1));
      for(size_t i = 0; i < list.size(); i++) {
         size_t start_idx = list.at(i).find(m_time_id) + id_len;
         size_t end_idx   = list.at(i).find(L".nrrd");
         size_t size = end_idx - start_idx;
         std::wstring fileno = list.at(i).substr(start_idx, size);
         TimeDataInfo info;
         info.filenumber = WSTOI(fileno);
         info.filename = list.at(i);
         m_4d_seq.push_back(info);
      }
   }
   if (m_4d_seq.size() > 0)
   {
      std::sort(m_4d_seq.begin(), m_4d_seq.end(), NRRDReader::nrrd_sort);
      for (int t=0; t<(int)m_4d_seq.size(); t++)
      {
         if (m_4d_seq[t].filename == m_path_name)
         {
            m_cur_time = t;
            break;
         }
      }
   }
   else
      m_cur_time = 0;

   //3D nrrd file
   m_chan_num = 1;
   //get time number
   m_time_num = (int)m_4d_seq.size();
}