30
Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

Embed Size (px)

Citation preview

Page 1: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

Pathology Visions 2007Customizing Spectrum for the Research Environment

Jim Deeds

23OCT2007

Page 2: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

2 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Outline

The research environment - differences from the clinical lab

PHP / SQL basics

Examples

• Welcome screen, added menu items, news, custom displays for users

• Projects (the heart of research work), users work spaces

• Custom reports / canned queries

• Using Spectrum as a LIMS

Analysis

Summary findings

Page 3: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

3 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

The research environment

There is great variety in the lab processes employed rather than a small number of well documented SOPs and clear work flow.

Specimens are often used in multiple ‘projects’

Slides need to be associated with projects (but also maintain a link to specimen data)

Users need flexibility / variation in queries and report format

Not all fields can use controlled vocabulary and often times users cannot remember which field contains the keyword they are looking for – how do you find anything?

Page 4: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

4 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Getting data in – the slide scanner as Trojan horse

Why is it difficult to get data entry done in a timely and accurate way?

• With conventional glass slides, it is easy to collect groups of slides in slide flats and attach paper forms with hand-written sample and staining details.

• There is no compelling reason to enter data into an electronic form until much later - if at all.

However, when slides are scanned, users must annotate them in order to find the images

• This is a perfect opportunity to help the user enter the meta data easily

• Provide a variety of search and custom report tools so that users have options to find their data

?

Page 5: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

5 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

The elements of CRUD

Custom interactions with the database can be built easily with PHP and SQL

The standard interactions with a database are sometimes referred to as ‘CRUD’

• Create: SQL INSERT

• Read: SQL SELECT

• Update: SQL UPDATE

• Delete: SQL DELETE

References:

http://www.w3schools.com/php/default.asp

http://www.php.net/

PHP and MySQL for dynamic web sites, Ullman L, (2005)

PHP Hacks: Tips & Tools for Creating Dynamic Web Sites, Herrington JD, (2005)

Page 6: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

6 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

The elements of CRUD: Query PHP Outline

//Connecting to the database$conn = odbc_connect("DRIVER={SQL Server};SERVER=myServer;DATABASE=aperio", “dbUser", “dbpassword" );

//Declaring the SQL query$sql = "select … ;";

//Executing the query$rs = odbc_exec($conn,$sql);

// Simple but unformatted display of the data$nr = odbc_result_all($res, "BGCOLOR='#f0f0f0' border=2 cellspacing=1");

//OR read results into variables and display with more formatecho "<table class='ListTable'cellspacing=0><tr>";

while (odbc_fetch_row($rs)){ echo "<tr class='row'>"; $field1=odbc_result($rs,"SpecimenID");$field2=odbc_result($rs,"Block");$field3=odbc_result($rs,"Prog")echo "<td><a href='EditRecord.php?TableName=Specimen&Ids[]=$field1'>$field1</td>";echo "<td>$field2</td>";echo "<td>$field3</td>";echo "</tr>";}

echo "</table>";

Direct database queries can be made using the PHP ‘odbc’ commandsRecords can be displayed using the stylesheet formatting for a consistent look and feel

Page 7: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

7 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

The elements of CRUD: example query

$sql = “SELECT

SpecimenID = sp.Id, Block = sp.AccessionNumber, Prog = sp.Column02, Tissue = sp.BodySite, Dx = sp.SpecimenReceived, Treatment = sp.Column01

, Stain = sl.Stain, SlideID = sl.Id, SlideParent = sl.Column10

, ImageID = im.ImageId

, AnnotID = ann.AnnotationId

, AnnotAttribID = anat.AnnotationAttributeId, AnnotAttribName = anat.AttributeName, AnnotAttribValue = anat.AttributeValue

FROM Aperio..Specimen sp, Aperio..Slide sl, Aperio..Image im, Aperio..Annotation ann, Aperio..AnnotationAttribute anat

WHERE sl.ParentTable = 'Specimen' AND sl.ParentId = sp.Id AND im.ParentTable = 'Slide' AND im.ParentId = sl.Id AND sl.Column10 = '$ParentId'AND ann.ImageId = im.ImageId AND anat.AnnotationId = ann.AnnotationId AND (anat.AttributeName = 'Percent Feature[3]' OR anat.AttributeName = 'Percent Feature[2]' OR anat.AttributeName = 'Percent Feature[1]' OR anat.AttributeName ='Percent Feature[0]')

ORDER BYsp.AccessionNumber,sl.Id,ann.AnnotationId,anat.AttributeName

;";

This example returns image analysis results for a specified project – ‘$ParentId’

Page 8: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

8 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Examples of custom reports / canned queries

Problem Reporting Solution

Users need to find information but are not sure of which table or field to search and/or how the search term was spelled.

‘Anything/anywhere’ (Google-like search)

DBA needs to identify data entry errors.Specimens and slides with common data entry problems

Managers need an up to date estimate of current project costs.

Reagent usage and estimated cost for each project (display number of specimens and stained slides produced and estimated FTE and dollar costs)

Users want to view only a few fields of image analysis data from all slides used in a particular project.

Extracted data from all slides belonging to a project (values + ‘bar graph display’)

Users want to know what new projects, specimens, slides and documents have been added since their last visit.

New records since last user visit / login

Page 9: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

9 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Welcome ScreenAdded menu items, news, custom displays for users…

Page 10: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

10 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Edit Project(1) modifications

This generates an ‘anything/anywhere’ search using our ‘external project ID’ as the keyword

These links display summary image analysis data from all slides used in this project

This displays all markup images generated by analysis algorithms, these markups can then be analyzed with other analysis tools – ‘chaining algorithms’.

Page 11: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

11 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Other Project Actions Show Related Items

Page 12: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

12 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Other Project Actions Show Data

Parent specimen Info Slide Info Algorithm Output Data

Page 13: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

13 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Edit Project(2) modifications

We use project images like figures in a publication. We have added a link to let users easily edit the ‘figure legend text’

Page 14: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

14 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Edit Project(3) modifications

This is an alternative view of project-associated specimens not using the Aperio ParentTable/ParentId mechanism.

This displays slides that have been directly associated with the project (i.e. – their parent specimen does not need to belong to the project)

Parent specimen Info Slide Info

Page 15: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

15 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Using Spectrum as a LIMS Functions added at Novartis

Vend unique specimen IDs with custom prefixes.

Vend unique slide IDs prior to slide scanning.

Upload specimen and slide data using excel sheets (xml format)

Antibody Table – links to protocols, spec sheets, gene IDs, slides stained

Automatically generate links to other labs specimen database

Page 16: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

16 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Using Spectrum as a LIMS Cautions

• Create new tables in the Aperio database for your new data – ideally these should be the only records that you modify.

• Be very careful about giving all users access to create, update and delete functions – especially those that affect Aperio generated tables.

• Use validation rules on data entry to insure that data entry matches field data type

• Security Basics:

- Using direct database calls can leave you vulnerable to a SQL-injection attack on your database (hackers with access to your website can delete/modify your data)

- Validate the contents of form fields to strip out SQL reserved characters

- Create a read-only database user for queries that are read-only (i.e. – select statements)

Page 17: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

17 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis

• Additional reports for analysis:- All Recent Jobs (links for Macro, Slide and Project details)

- Macro details

• Auto-circling MATLAB tool

• General purpose pixel classifier -> regions of analysis (chaining)

• Optimizing parameters for IHC NUC

Page 18: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

18 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis Show All Recent JobsBrowse to macro, slide and project details

Page 19: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

19 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis - Auto-tissuefinder Auto-circling multiple pieces of tissue

MatLAB tool opens svs files through Aperio API, finds tissue and generates selection layers for each piece of tissue. An sis file can be used to submit multiple slides.

Page 20: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

20 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis – Pixel Classifier Schematic

Why?

Need a general purpose tool to measure %s of different cell types in a section (e.g. - % tumor)

Need to automate selection of regions for analysis (e.g. - nuclear count algorithm run on only the viable tumor cells)

Image db

ImageScope

ComLineAlgorithm*

Inputimage

tile

Outputimage

tile

Markupimage

SPECTRUM

ClassifierProgram

Seg file

* Developed with ImageScope SDK, collaboration with Allen Olson.

Page 21: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

21 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis– Pixel Classifier Example

We can measure these areasGreen: viable tumor (55%)Red: fibroblasts (36%)Blue necrosis (9%)

Page 22: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

22 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis– Pixel Classifier chaining with other algorithms

9% positive

Pixel classify

ColorDeconv

ColorDeconv

15% positive

Page 23: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

23 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis optimizing parameters for the IHC Nuclear algorithm

Generally, we typically use these as our starting settings (parameters highlighted in yellow are most critical):

The two parameters which appear to influence correct segmentation of nuclei are ‘averaging radius’ and ‘curvature threshold’ (see next slide).

Attribute ValueAlgorithm IHC Nuclear AlgorithmAveraging Radius (um) 1Curvature Threshold 2.5Segmentation Type 2 - Cytoplasmic RejectionThreshold Type 1 - Edge Threshold MethodLower Intensity Threshold 0Upper Intensity Threshold 235Min Nuclear Size (um^2) 10Max Nuclear Size (um^2) 1000Min Roundness 0Min Compactness 0Min Elongation 0Remove Light Objects 0Weak(1+) Threshold 210Moderate(2+) Threshold 150Strong(3+) Threshold 100Black Threshold 0Edge Trim WeigtedMarkup Image Type Analysis (Edges Only)Clear Area Intensity 240

Page 24: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

24 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Increasing ‘Curvature Threshold’

Increasing ‘Averaging R

adius’

Analysis effect of varying two parameters (IHC-NUC)

These parameters appear to most accurately segment nuclei

Page 25: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

25 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis effect of varying two parameters (IHC-NUC)

Increasing ‘Curvature Threshold’

Incre

asin

g ‘Ave

rag

ing

Ra

diu

s’

0

10

20

30

40

50

60

70

80

90

AvR0_Cur0 AvR2_Cur0 AvR4_Cur0 AvR0_Cur2 AvR2_Cur2 AvR4_Cur2 AvR0_Cur4 AvR2_Cur4 AvR4_Cur4

% P

os

Nu

c

0

100

200

300

400

500

600

700

Ave

Nu

c S

ize

% pos nuc

Ave nuc size

Over these ranges of parameters, percent positive nuclei values vary from 45 – 75%

Page 26: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

26 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

The expected average nuclear size is ~150 pixels.

Any parameters which produce nuclei around this size appear to yield a % positive nuclei value around 62%.

Could average nuclear size be used to QC adequacy of analysis parameters?

Are there a fairly wide range of parameters that would still yield quality results?

y = 1.8059x2 - 227.84x + 7307.6

R2 = 0.9466

0

100

200

300

400

500

600

700

40 45 50 55 60 65 70 75 80

% Pos Nuc

Ave

Nuc

Siz

e

Analysis effect of varying two parameters (IHC-NUC)

Page 27: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

27 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Summary

PHP is easy to learn and very powerful. A bench biologist can learn enough to start adding useful features quickly.

Whenever possible, provide links forward and back between objects (main three tables but also for documents, data results, analysis batches, macro details…)

Build in protocycle mode rather than top down uber-design

A primary challenge of any laboratory system is to get data entered in a timely and consistent manner

• Help the user by streamlining data entry

• Provide a payoff - easy access to their data via reports and auto-filtering

• Transparency about who is entering data promotes healthy competition and helps users share ideas.

• Start getting data in as soon as possible so that you understand the real data entry issues to deal with (you will focus on major issues rather than nice-to-have features). Data can be cleaned later.

Page 28: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

28 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Contributions

Hanif Khalak, Quan Yang – IT

Jon Baron – PathTRAC

Judy Shim – Database Administrator

Yan Gao, Helen He, Ron Meyer, Lance Ostrom, Min He, Jane Gu – System Users / Testers

Beccy Mosher – Pathologist

Bob Schlegel, Bill Sellers – Support and Vision

Page 29: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

29 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Additional Slides

Page 30: Pathology Visions 2007 Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007

30 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007

Analysis Submit multiple analyses

Example: run a set of nine macros on the same image(s) to evaluate the effect of varying ‘curvature threshold’ and ‘averaging radius’ parameters between 0 and 3:

IHCOPT_AR0_CT0IHCOPT_AR0_CT15IHCOPT_AR0_CT30IHCOPT_AR15_CT0IHCOPT_AR15_CT15IHCOPT_AR15_CT30IHCOPT_AR30_CT0IHCOPT_AR30_CT15IHCOPT_AR30_CT15

To use:

• Select slides to be analyzed in Spectrum

• Click ‘Analyze’ link

• Select input annotation layer to be analyzed and select analysis macro: ‘IHCOPT_MULTI_1’

• Click ‘Analyze’ button.

• All nine algorithms will be run on your slide(s).