def generate_annotation_set(retina_grader=False): grader = UserFactory() if retina_grader: add_to_graders_group([grader]) measurement = MeasurementAnnotationFactory(grader=grader) boolean = BooleanClassificationAnnotationFactory(grader=grader) integer = IntegerClassificationAnnotationFactory(grader=grader) polygon = PolygonAnnotationSetFactory(grader=grader) coordinatelist = CoordinateListAnnotationFactory(grader=grader) landmark = LandmarkAnnotationSetFactory(grader=grader) etdrs = ETDRSGridAnnotationFactory(grader=grader) # Create child models for polygon annotation set SinglePolygonAnnotationFactory.create_batch(10, annotation_set=polygon) # Create child models for landmark annotation set (3 per image) for i in range(5): image = ImageFactory() SingleLandmarkAnnotationFactory(annotation_set=landmark, image=image) return AnnotationSet( grader=grader, measurement=measurement, boolean=boolean, polygon=polygon, coordinatelist=coordinatelist, landmark=landmark, etdrs=etdrs, integer=integer, )
def generate_annotation_set(retina_grader=False, image=False): grader = UserFactory() if retina_grader: add_to_graders_group([grader]) create_options = {"grader": grader} if image: create_options_with_image = {"image": image, **create_options} else: create_options_with_image = create_options measurement = MeasurementAnnotationFactory(**create_options_with_image) boolean = BooleanClassificationAnnotationFactory( **create_options_with_image ) integer = IntegerClassificationAnnotationFactory( **create_options_with_image ) polygon = PolygonAnnotationSetFactory(**create_options_with_image) coordinatelist = CoordinateListAnnotationFactory( **create_options_with_image ) etdrs = ETDRSGridAnnotationFactory(**create_options_with_image) landmark = LandmarkAnnotationSetFactory(**create_options) # Create child models for polygon annotation set SinglePolygonAnnotationFactory.create_batch(10, annotation_set=polygon) # Create child models for landmark annotation set (3 per image) single_landmarks = [] for i in range(5): if i > 0 or not image: image = ImageFactory() single_landmarks.append( SingleLandmarkAnnotationFactory( annotation_set=landmark, image=image ) ) return AnnotationSet( grader=grader, measurement=measurement, boolean=boolean, polygon=polygon, coordinatelist=coordinatelist, landmark=landmark, singlelandmarks=single_landmarks, etdrs=etdrs, integer=integer, )
def create_load_data(data_type, ds, grader): if data_type == "Registration": model = LandmarkAnnotationSetFactory(grader=grader) SingleLandmarkAnnotationFactory( annotation_set=model, image=ds["image_cf"] ), if ds["archive"].name == "Australia": # Australia does not allow obs images so create a new cf image for Australia test img = ImageFactory(study=ds["study"]) SingleLandmarkAnnotationFactory(annotation_set=model, image=img) else: SingleLandmarkAnnotationFactory( annotation_set=model, image=ds["image_obs"] ), elif data_type == "ETDRS": model = ETDRSGridAnnotationFactory(grader=grader, image=ds["image_cf"]) elif data_type == "GA" or data_type == "kappa": model_macualar = PolygonAnnotationSetFactory( grader=grader, image=ds["image_cf"], name="macular" ) SinglePolygonAnnotationFactory(annotation_set=model_macualar) SinglePolygonAnnotationFactory(annotation_set=model_macualar) SinglePolygonAnnotationFactory(annotation_set=model_macualar) model_peripapillary = PolygonAnnotationSetFactory( grader=grader, image=ds["image_cf"], name="peripapillary" ) SinglePolygonAnnotationFactory(annotation_set=model_peripapillary) SinglePolygonAnnotationFactory(annotation_set=model_peripapillary) SinglePolygonAnnotationFactory(annotation_set=model_peripapillary) model = [model_macualar, model_peripapillary] elif data_type == "Measure": model = [ MeasurementAnnotationFactory(grader=grader, image=ds["image_cf"]), MeasurementAnnotationFactory(grader=grader, image=ds["image_cf"]), MeasurementAnnotationFactory(grader=grader, image=ds["image_cf"]), ] elif data_type == "Fovea": model = BooleanClassificationAnnotationFactory( grader=grader, image=ds["image_cf"], name="fovea_affected" ) return model