rpt_dosi.db =========== .. py:module:: rpt_dosi.db Classes ------- .. autoapisummary:: rpt_dosi.db.PatientTreatmentDatabase rpt_dosi.db.CycleTreatmentDatabase rpt_dosi.db.TimepointTreatmentDatabase Functions --------- .. autoapisummary:: rpt_dosi.db.db_get_time_interval rpt_dosi.db.create_test_db rpt_dosi.db.compute_time_activity_curve Module Contents --------------- .. py:function:: db_get_time_interval(cycle, acquisition) .. py:class:: PatientTreatmentDatabase(filename, create=False, sync_metadata_image=False) Bases: :py:obj:`rpt_dosi.metadata.ClassWithMetaData` Store information about a patient treatment: - all cycles, all imaging timepoints - consider a hierarchy folders patient/cycle_id/timepoint_id/images - from / to json files - when store to a json file, the database folder MUST be the one of the json file patient/ db.json cycle1/ tp1/ ct.nii.gz spect.nii.gz tp2/ ... cycle2/ ... .. py:attribute:: _metadata_fields .. py:attribute:: patient_id :value: None .. py:attribute:: body_weight_kg :value: None .. py:attribute:: cycles .. py:attribute:: _db_file_path :value: None .. py:attribute:: _db_data_path :value: None .. py:method:: info() .. py:property:: db_data_path .. py:property:: db_file_path .. py:method:: __str__() .. py:method:: number_of_timepoints() .. py:method:: number_of_rois() .. py:method:: number_of_images() .. py:method:: get_cycle(cycle_id) .. py:method:: __getitem__(key) .. py:method:: add_cycle(cycle) .. py:method:: remove_cycle(cycle_id) .. py:method:: add_new_cycle(cycle_id) .. py:method:: add_dicom_ct(cycle_id, tp_id, folder_path) .. py:method:: write(filename=None, sync_metadata_image=True, sync_policy='auto') .. py:method:: write_metadata_images() .. py:method:: sync_metadata_images(sync_policy='auto') .. py:method:: read(filename, sync_metadata_image) .. py:method:: to_dict() Store the metadata attributes to a dictionary. .. py:method:: from_dict(data) Set the metadata attributes of the instance from a dictionary. .. py:method:: check_folders_exist() .. py:method:: check_files_exist() .. py:method:: check_files_metadata() .. py:class:: CycleTreatmentDatabase(db, cycle_id) Bases: :py:obj:`rpt_dosi.metadata.ClassWithMetaData` Class to manage metadata, providing methods to convert to/from dict and JSON. The class fields that are considered as metadata are store in _metadata_fields. .. py:attribute:: _metadata_fields .. py:attribute:: db .. py:attribute:: cycle_id .. py:attribute:: injection_activity_mbq :value: None .. py:attribute:: _injection_datetime :value: None .. py:attribute:: injection_radionuclide :value: None .. py:attribute:: timepoints .. py:method:: info() .. py:method:: __str__() .. py:property:: injection_datetime .. py:method:: get_timepoint(tp_id) .. py:method:: __getitem__(key) .. py:method:: add_timepoint(tp) .. py:method:: add_new_timepoint(tp_id) .. py:property:: cycle_path .. py:method:: to_dict() Store the metadata attributes to a dictionary. .. py:method:: from_dict(data) Set the metadata attributes of the instance from a dictionary. .. py:method:: sync_metadata_images(sync_policy='auto') .. py:method:: write_metadata_images() .. py:method:: check_folders_exist() .. py:method:: check_files_exist() .. py:method:: check_files_metadata() .. py:class:: TimepointTreatmentDatabase(cycle, tp_id) Bases: :py:obj:`rpt_dosi.metadata.ClassWithMetaData` Store filenames, not paths, paths are computed on the fly. The folders are build from db/cycle/timepoint .. py:attribute:: _metadata_fields .. py:attribute:: cycle .. py:attribute:: timepoint_id .. py:attribute:: _acquisition_datetime :value: None .. py:attribute:: images .. py:attribute:: rois .. py:method:: info() .. py:method:: __str__() .. py:method:: to_dict() Store the metadata attributes to a dictionary. .. py:method:: from_dict(data) Set the metadata attributes of the instance from a dictionary. .. py:property:: acquisition_datetime .. py:method:: sync_metadata_images(sync_policy='auto') .. py:method:: sync_metadata_image(image_name, sync_policy='auto') .. py:method:: sync_metadata_roi(roi_name, sync_policy='auto') .. py:method:: write_metadata_images() .. py:property:: timepoint_path .. py:property:: rois_path .. py:method:: get_roi(roi_id) .. py:method:: get_roi_path(roi_id) .. py:method:: get_metaimage(image_name) .. py:method:: get_image_file_path(image_name) .. py:property:: time_from_injection_h .. py:method:: add_image_from_file(image_name, input_path, image_type=None, filename=None, mode='copy', unit=None, file_exist_ok=False) .. py:method:: add_image(image_name, meta_image) .. py:method:: add_rois(roi_list, mode='copy', exist_ok=False) .. py:method:: add_roi(roi) .. py:method:: add_roi_from_file(roi_id, input_path, mode='copy', exist_ok=False) .. py:method:: check_folders_exist() .. py:method:: check_files_exist() .. py:method:: check_files_metadata() .. py:function:: create_test_db(data_folder, db_file_path) .. py:function:: compute_time_activity_curve(cycle, roi_names, spect_name='spect')