ispyb / ispyb-database-modeling

4 stars 3 forks source link

Automatic scoring of drop images #50

Closed KarlLevik closed 3 years ago

KarlLevik commented 4 years ago

We have been looking at implementing automatic scoring of drop images, and have come up with the following three tables which I hereby propose as changes to the ISPyB collaboration schema.

As you can see, BLSampleImageAutoScoreClass - the "thing" being scored (crystal, precipitant etc), is a child of BLSampleImageAutoScoreSchema which is basically just the name of the schema and whether it's currently enabled.

Then the last table, BLSampleImage_has_AutoScoreClass, enables a many-to-many relationship between BLSampleImage (drop images) and BLSampleImageAutoScoreClass (thing being scored), and at the same time contains the actual score value - the probability column - which gives us the probability that the drop image contains that thing.

CREATE TABLE BLSampleImageAutoScoreSchema (
  blSampleImageAutoScoreSchemaId tinyint(3) unsigned auto_increment PRIMARY KEY,
  schemaName varchar(25) NOT NULL COMMENT 'Name of the schema e.g. Hampton, MARCO',
  enabled tinyint(1) DEFAULT 1 COMMENT 'Whether this schema is enabled (could be configurable in the UI)'
) COMMENT 'Scoring schema name and whether it is enabled';

CREATE TABLE BLSampleImageAutoScoreClass (
  blSampleImageAutoScoreClassId tinyint(3) unsigned auto_increment PRIMARY KEY,
  blSampleImageAutoScoreSchemaId tinyint(3) unsigned,
  scoreClass varchar(15) NOT NULL COMMENT 'Thing being scored e.g. crystal, precipitant',
  CONSTRAINT BLSampleImageAutoScoreClass_fk1 FOREIGN KEY (blSampleImageAutoScoreSchemaId) REFERENCES BLSampleImageAutoScoreSchema(blSampleImageAutoScoreSchemaId) ON DELETE NO ACTION ON UPDATE CASCADE
) COMMENT 'The automated scoring classes - the thing being scored';

CREATE TABLE BLSampleImage_has_AutoScoreClass (
  blSampleImageId int(11) unsigned NOT NULL,
  blSampleImageAutoScoreClassId tinyint(3) unsigned,
  probability float,
  PRIMARY KEY (blSampleImageId, blSampleImageAutoScoreClassId),
  CONSTRAINT BLSampleImage_has_AutoScoreClass_fk1 FOREIGN KEY (blSampleImageId) REFERENCES BLSampleImage(blSampleImageId) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT BLSampleImage_has_AutoScoreClass_fk2 FOREIGN KEY (blSampleImageAutoScoreClassId) REFERENCES BLSampleImageAutoScoreClass(blSampleImageAutoScoreClassId) ON DELETE CASCADE ON UPDATE CASCADE
) COMMENT 'Many-to-many relationship between drop images and thing being scored, as well as the actual probability (score) that the drop image contains that thing';
KarlLevik commented 3 years ago

ISPyB dev. collaboration meeting 2020-09-09: As crystal imaging within ISPyB is only done at Diamond, we decided not to include this in the ISPyB collaboration schema.