Ejemplo n.º 1
0
 def get_subjects(self):
     organized_directory = self.get_organized_directory()
     analysis_cls = AnalysisFactory.get_analysis_cls(self._analysis_type)
     temp_study = Study('IntraAnalysis',
                        output_directory=organized_directory)
     QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
     subjects = temp_study.get_subjects_from_pattern()
     QtGui.QApplication.restoreOverrideCursor()
     return subjects
Ejemplo n.º 2
0
class AbstractStudyTestCase(object):

    def __init__(self):
        self.study = None
        self.analysis_type = None
        self.studyname = None
        self.output_directory = None
        self.subjectnames = None
        self.groupnames = None
        self.filenames = None

    def create_study(self):
        self.study = Study(analysis_type=self.analysis_type,
                           study_name=self.studyname,
                           output_directory=self.output_directory)
        return self.study

    def add_subjects(self):
        for subjectname, groupname, filename in zip(self.subjectnames,
                                    self.groupnames, self.filenames):
            subject = Subject(subjectname, groupname, filename)
            self.study.add_subject(subject)

    def delete_some_input_files(self):
        raise NotImplementedError("AbstractStudyTestCase is an abstract class")

    def create_some_output_files(self):
        raise NotImplementedError("AbstractStudyTestCase is an abstract class")

    def restore_input_files(self):
        raise NotImplementedError("AbstractStudyTestCase is an abstract class")

    def step_to_wait_testcase_1(self):
        raise NotImplementedError("AbstractStudyTestCase is an abstract class")

    def step_to_wait_testcase_2(self):
        raise NotImplementedError("AbstractStudyTestCase is an abstract class")

    def step_to_wait_testcase_3(self):
        raise NotImplementedError("AbstractStudyTestCase is an abstract class")

    def get_a_subject_id(self):
        first_subject_id = next(six.iterkeys(self.study.subjects))
        return first_subject_id
Ejemplo n.º 3
0
    def test_save_load_study(self):
        self.test_case.add_subjects()

        studyfilepath = self.study.backup_filepath
        studyfilepath2 = studyfilepath + "_2"
        if os.path.isfile(studyfilepath): os.remove(studyfilepath)
        if os.path.isfile(studyfilepath2): os.remove(studyfilepath2)
        self.study.save_to_backup_file()
        shutil.move(studyfilepath, studyfilepath2)

        loaded_study = Study.from_file(studyfilepath2)
        loaded_study.save_to_backup_file()

        self.assert_(filecmp.cmp(studyfilepath, studyfilepath2))
Ejemplo n.º 4
0
 def create_updated_study(self, progress_callback=None):
     old_vol_format = self.study.volumes_format
     old_mesh_format = self.study.meshes_format
     # create a new study to avoid modifying the existing one (we may be
     # called from a thread here)
     serialized_study = self.study.serialize()
     study = Study.unserialize(serialized_study,
                               self.study.output_directory)
     self._study_properties_editor.update_study(study)
     self._subjects_editor.update_study(
         study, self.study_update_policy)
     study.convert_from_formats(old_vol_format, old_mesh_format,
                                progress_callback)
     self.study = study  # WARNING whe change the study in a thread.
     return self.study
Ejemplo n.º 5
0
 def create_study(self):
     self.study = Study(analysis_type=self.analysis_type,
                        study_name=self.studyname,
                        output_directory=self.output_directory)
     return self.study