def setUpClass(cls):
        # Set up a database connection
        cls.db = Database.from_key('tests/credentials',
                                   'config/credentials.key')

        # Select a patient
        query = 'SELECT TOP(1) ID, patientID FROM patientRepresentations'
        res = cls.db.run(query)
        cls.patientRepID = res.rows[0].ID

        # Get a dose grid for a patient
        res0 = cls.db.radiotherapy_sessions.get_session_ids(cls.patientRepID)
        cls.dg = cls.db.radiotherapy_sessions.get_dose_grid(res0.rows[0][0])

        def roi_query_helper(prepID):
            '''
            Get all ROI's for a patient ID
            '''
            query = '''
                SELECT TOP(1) patientRepID, ID, name
                FROM RegionsOfInterest
                WHERE patientRepID = {}
                ORDER BY name asc
            '''.format(prepID)
            return cls.db.run(query).rows[0]

        # Store patientRepID and name of ROIs with a certain number of occurrences
        res1 = roi_query_helper(cls.patientRepID)

        res2 = cls.db.regions_of_interest.get_id_by_patient_rep_id_name(
            res1.patientRepID, str(res1.name))

        cls.mask = cls.db.regions_of_interest.get_mask(res2)
        # Create a dose mask
        cls.dm = DoseMask(cls.mask, cls.dg)
    def setUpClass(cls):
        # Set up a database connection
        cls.db = Database.from_key('tests/credentials',
                                   'config/credentials.key')

        # Select a patient
        query = 'SELECT TOP(1) ID, patientID FROM patientRepresentations'
        res = cls.db.run(query)
        cls.patientRepID = res.rows[0].ID
        cls.patientID = res.rows[0].patientID

        def roi_query_helper(count):
            '''
            Get a patientRepID and ROI name that appears a certain number of times
            '''
            query = '''
                WITH query1 as (
                    SELECT patientRepID, name, count(*) as count
                    FROM RegionsOfInterest
                    GROUP BY name, patientRepID
                )
                SELECT TOP(1) * FROM query1 WHERE count = {}
            '''.format(count)
            res = cls.db.run(query)
            return res.rows[0]

        # Store patientRepID and name of ROIs with a certain number of occurrences
        res0 = roi_query_helper(1)
        cls.one_roi = [res0.patientRepID, str(res0.name)]
        res1 = roi_query_helper(2)
        cls.many_rois = [res1.patientRepID, str(res1.name)]
示例#3
0
    def setUpClass(cls):
        # Set up a database connection
        cls.db = Database.from_key('tests/credentials',
                                   'config/credentials.key')

        # Select a patient
        query = 'SELECT TOP(1) ID, patientID FROM patientRepresentations'
        res0 = cls.db.run(query)
        cls.patientRepID = res0.rows[0].ID

        def roi_query_helper(prepID):
            '''
            Get all ROI's for a patient ID
            '''
            query = '''
                SELECT TOP(2) patientRepID, ID, name
                FROM RegionsOfInterest
                WHERE patientRepID = {}
                ORDER BY name asc
            '''.format(prepID)
            return cls.db.run(query).rows

        # Store patientRepID and a few ROI names and IDs
        res1 = roi_query_helper(cls.patientRepID)
        # Get a few masks
        res2, _ = cls.db.regions_of_interest.get_masks(
            cls.patientRepID, [str(r.name) for r in res1])
        cls.masks = list(res2.values())
    def setUpClass(cls):
        # Set up a database connection
        cls.db = Database.from_key('tests/credentials',
                                   'config/credentials.key')

        query = 'SELECT TOP(1) patientID FROM Patients'
        res = cls.db.run(query)
        cls.patientID = res.rows[0].patientID
    def setUpClass(cls):
        # Set up a database connection
        cls.db = Database.from_key('tests/credentials',
                                   'config/credentials.key')

        cls.rois = ['l_parotid', 'r_parotid']
        prepIDs = cls.db.regions_of_interest.get_patient_rep_ids_with_rois(
            cls.rois)
        if len(prepIDs) >= 2:
            cls.patientRep_1 = prepIDs[0]
            cls.patientRep_2 = prepIDs[1]
示例#6
0
    def setUpClass(cls):
        # Set up a database connection
        cls.db = Database.from_key('tests/credentials',
                                   'config/credentials.key')

        # Select a patient
        query = 'SELECT TOP(1) ID, patientID FROM patientRepresentations'
        res = cls.db.run(query)
        cls.patientRepID = res.rows[0].ID
        cls.patientID = res.rows[0].patientID

        # Files to delete
        cls.file_path = 'tests/files/'
        cls.to_remove = []
示例#7
0
    def setUpClass(cls):
        # Set up a database connection
        cls.db = Database.from_key('tests/credentials',
                                   'config/credentials.key')

        # Select a patient
        query = 'SELECT TOP(1) ID, patientID FROM patientRepresentations'
        res = cls.db.run(query)
        cls.patientRepID = res.rows[0].ID
        cls.patientID = res.rows[0].patientID

        res = cls.db.radiotherapy_sessions.get_session_ids(cls.patientRepID)
        # Normal dose grid
        cls.dg = cls.db.radiotherapy_sessions.get_dose_grid(res.rows[0][0])
        # Scaled dose grid
        cls.dg_scaled = cls.db.radiotherapy_sessions.get_dose_grid(
            res.rows[0][0])
        cls.dg_scaled.dose_scaling_factor = 0.5
    def setUpClass(cls):
        # Set up a database connection
        cls.db = Database.from_key('tests/credentials',
                                   'config/credentials.key')

        # Select a patient
        query = 'SELECT TOP(1) ID, patientID FROM patientRepresentations'
        res = cls.db.run(query)
        cls.patientRepID = res.rows[0].ID

        def roi_query_helper(prepID):
            '''
            Get all ROI's for a patient ID
            '''
            query = '''
                SELECT TOP(1) patientRepID, ID, name
                FROM RegionsOfInterest
                WHERE patientRepID = {}
                ORDER BY name asc
            '''.format(prepID)
            return cls.db.run(query).rows[0]

        # Store patientRepID and name of ROIs with a certain number of occurrences
        res1 = roi_query_helper(cls.patientRepID)

        res2 = cls.db.regions_of_interest.get_id_by_patient_rep_id_name(
            res1.patientRepID, str(res1.name))

        base_mask = cls.db.regions_of_interest.get_mask(res2)
        # Make one mask that is contiguous
        cont_pts = [[i, j, k] for i in range(10) for j in range(10)
                    for k in range(10)]
        cls.good_mask = tf.general.fill_mask(base_mask, cont_pts)
        # And create one that is discontiguous
        discont_pts = [[i, j, k] for i in range(10) for j in range(10)
                       for k in range(10) if k < 4 or k > 5]
        cls.bad_mask = tf.general.fill_mask(base_mask, discont_pts)