Exemple #1
0
def test_load_save(jobfile):
    jconf = load_json_ordered(jobfile)
    print(jconf)
    j = run_jobconf(jconf)

    outd = job.dump(j)
    print(outd)
    run_jobconf(outd)
    save_json_ordered('saved_' + jobfile, outd)
Exemple #2
0
def gen_scan_info(infolder, outfolder):
    """
	Generate scan_info.json file from dicom files.

	Use one random dicom file.
	"""
    di = find_scan_dicom_info(infolder)
    d = di.get_scan_info()
    scanInfoFile = os.path.join(outfolder, 'scan_info.json')
    loadsave.save_json_ordered(scanInfoFile, d)
Exemple #3
0
def gen_scan_info(infolder, outfolder):
    """
	Generate scan_info.json file from dicom files.

	Use one random dicom file.
	"""
    found = False
    for dirpath, dirnames, filenames in os.walk(infolder):
        if not found:
            for filename in filenames:
                try:
                    pydicom.read_file(os.path.join(dirpath, filename))
                    found = True
                except:
                    pass
                if found:
                    di = DicomInfo(os.path.join(dirpath, filename))
                    d = di.get_scan_info()
                    scanInfoFile = os.path.join(outfolder, 'scan_info.json')
                    loadsave.save_json_ordered(scanInfoFile, d)
Exemple #4
0
        d['Manufacturer'] = self.manufacturer()
        d['ManufacturerModelName'] = self.modelname()
        return d

    def get_scan_info(self):
        d = OrderedDict()
        d['StudyDate'] = self.studydate()
        d['Machine'] = self.machine()
        d['Patient'] = self.patient()
        return d

    def print_core(self):
        print(self.studydate())
        print(self.institution())
        print(self.manufacturer())
        print(self.modelname())
        print(self.patient())

    def print_all(self):
        print(self.plan)


if __name__ == '__main__':
    di = DicomInfo('data_dicom/yangyubo_20180119/SE0/IM0')
    #di.print_all()
    di.print_core()
    d = di.get_scan_info()
    print()
    print(d)
    loadsave.save_json_ordered('test_scan_info.json', d)
Exemple #5
0
 def cb_menu_Save(self):
     resname = tktools.asksaveasfilename()
     if resname:
         d = self.connector.field_to_config(self.rootfield)
         save_json_ordered(resname, d)
         print('Saved to {}'.format(resname))
Exemple #6
0
 def cb_menu_Save(self):
     d = self.connector.field_to_config(self.rootfield)
     save_json_ordered(self.configfile_path, d)
     print('Saved to {}'.format(self.configfile_path))