300 likes | 447 Views
Pathology Visions 2007 Customizing Spectrum for the Research Environment. Jim Deeds 23OCT2007. Outline. The research environment - differences from the clinical lab PHP / SQL basics Examples Welcome screen, added menu items, news, custom displays for users
E N D
Pathology Visions 2007Customizing Spectrum for the Research Environment Jim Deeds 23OCT2007
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 2 | 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? 3 | 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 ? 4 | 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) 5 | 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 format echo "<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’ commands Records can be displayed using the stylesheet formatting for a consistent look and feel 6 | 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 BY sp.AccessionNumber ,sl.Id ,ann.AnnotationId ,anat.AttributeName ;"; This example returns image analysis results for a specified project – ‘$ParentId’ 7 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Examples of custom reports / canned queries 8 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Welcome Screen Added menu items, news, custom displays for users… 9 | 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’. 10 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Other Project Actions Show Related Items 11 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Other Project Actions Show Data Parent specimen Info Algorithm Output Data Slide Info 12 | 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’ 13 | 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) 14 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007 Parent specimen Info Slide Info
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 15 | 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) 16 | 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 17 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Browse to macro, slide and project details Analysis Show All Recent Jobs 18 | 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. 19 | 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) Markup image ImageScope SPECTRUM Seg file Image db Input image tile Output image tile Classifier Program ComLine Algorithm* * Developed with ImageScope SDK, collaboration with Allen Olson. 20 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Analysis– Pixel Classifier Example We can measure these areas Green: viable tumor (55%) Red: fibroblasts (36%) Blue necrosis (9%) 21 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Analysis– Pixel Classifier chaining with other algorithms 9% positive Color Deconv Pixel classify Color Deconv 15% positive 22 | 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). 23 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Analysis effect of varying two parameters (IHC-NUC) Increasing ‘Curvature Threshold’ These parameters appear to most accurately segment nuclei Increasing ‘Averaging Radius’ 24 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Analysis effect of varying two parameters (IHC-NUC) Increasing ‘Curvature Threshold’ Increasing ‘Averaging Radius’ % pos nuc Ave nuc size Over these ranges of parameters, percent positive nuclei values vary from 45 – 75% 25 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Analysis effect of varying two parameters (IHC-NUC) 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? 26 | 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. 27 | 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 28 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007
Additional Slides 29 | 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_CT0 IHCOPT_AR0_CT15 IHCOPT_AR0_CT30 IHCOPT_AR15_CT0 IHCOPT_AR15_CT15 IHCOPT_AR15_CT30 IHCOPT_AR30_CT0 IHCOPT_AR30_CT15 IHCOPT_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). 30 | Visions 2007 | Spectrum for Research | Jim Deeds | 22OCT2007