Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
STIR
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
STIR Howto Create Custom InputFileFormat
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Creating classes for reading events == Again, files for ECAT962 provide some example. You need to create a class for cLMD from your scanner, which inherits from CListModeData. A minimal example header file looks like <pre> template <class CListRecordT> class CListModeDataMyScanner : public CListModeData { public: CListModeDataMyScanner( const std::string& listmode_filename_prefix); virtual std::string get_name() const; virtual shared_ptr <CListRecord> get_empty_record_sptr() const; virtual Succeeded get_next_record(CListRecord& record_of_general_type) const; virtual Succeeded reset(); virtual SavedPosition save_get_position(); virtual Succeeded set_get_position(const SavedPosition&); virtual bool has_delayeds() const; private: std::string listmode_filename_prefix; mutable shared_ptr<InputStreamWithRecords<CListRecordT, bool> > current_lm_data_ptr; mutable std::vector< unsigned int> saved_get_positions; Succeeded open_lm_file() const; }; </pre> There are also two inherited data members * shared_ptr<Scanner> scanner_sptr * shared_ptr<ExamInfo> exam_info_sptr which have to be set in the derived class. The filename of the file to be read has to be given as an argument to the constructor. It does the following: * Set inherited exam info pointer. Minimum: set empty ExamInfo ** this->exam_info_sptr.reset(new ExamInfo); * Set inherited Scanner pointer. If user-defined scanner, do something like this <pre> scanner_sptr.reset(new Scanner(Scanner::User_defined_scanner, "MyScanner", 124, 63, // int num_detectors_per_ring_v, int num_rings_v, 120, // int max_num_non_arccorrected_bins_v, 120, // int default_num_arccorrected_bins_v, 63, 10.0, // float inner_ring_radius_v, float average_depth_of_interaction_v, 3.2, 1.2, 0.0, // float ring_spacing_v, float bin_size_v, float intrinsic_tilt_v, 1, 2, // int num_axial_blocks_per_bucket_v, int num_transaxial_blocks_per_bucket_v, 1, 1, // int num_axial_crystals_per_block_v, int num_transaxial_crystals_per_block_v, 1, // int num_axial_crystals_per_singles_unit_v, 1, // int num_transaxial_crystals_per_singles_unit_v, 1 // int num_detector_layers_v); )); </pre> * call open_lm_file(). This function in a minimal version looks like <pre> template <class CListRecordT> Succeeded CListModeDataMyScanner<CListRecordT>:: open_lm_file() const { // Could put something here to fiddle with file extensions, let's assume listmode_filename_prefix=filename cerr << "CListModeDataMyScanner: opening file " << listmode_filename_prefix << endl; shared_ptr<istream> stream_ptr(new fstream(listmode_filename_prefix.c_str(), ios::in | ios::binary )); if(!(*stream_ptr)) { warning("CListModeDataMyScanner: cannot open file %s\n", filename.c_str()); return Succeeded::no; } stream_ptr->seekg(32); // first 32 bytes of file used for signature, thus move stream forward. current_lm_data_ptr.reset( new InputStreamWithRecords<CListRecordT, bool> ( stream_ptr, sizeof(CListTimeDataMyScanner), sizeof(CListTimeDataMyScanner), ByteOrder::little_endian !=ByteOrder::get_native_order())); // Pay attention to byte order in your binary file! return Succeeded::yes; } </pre> Last thing to do is to create an instance of your templated class by * template class CListModeDataMyScanner<CListRecordMyScanner>;
Summary:
Please note that all contributions to STIR may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
STIR:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width