{"id":2396,"date":"2012-05-29T09:04:27","date_gmt":"2012-05-29T13:04:27","guid":{"rendered":"http:\/\/labrigger.com\/blog\/?p=2396"},"modified":"2012-05-29T09:04:27","modified_gmt":"2012-05-29T13:04:27","slug":"z-projections","status":"publish","type":"post","link":"http:\/\/labrigger.com\/blog\/2012\/05\/29\/z-projections\/","title":{"rendered":"Z-Projections"},"content":{"rendered":"<p align=\"center\"><a href=\"http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2012\/05\/Comparison.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2012\/05\/Comparison_sm.png\" alt=\"\" title=\"Comparison of different Z-projection algorithms. Click for larger version.\" width=\"600\" height=\"191\" class=\"aligncenter size-full wp-image-2398\" srcset=\"http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2012\/05\/Comparison_sm.png 600w, http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2012\/05\/Comparison_sm-300x95.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>To project 3D image stacks to a 2D image, several different algortithms can be used. Maximum projections and averages are the most commonly used. Neither of these yield nice black backgrounds. In fact, maximum projections maximize the noise in the background. There are other options that do yield black backgrounds, including standard deviation projections and &#8220;smart&#8221; average projections (code and details below).<\/p>\n<p>The best projection to use will depend on the source data and what type of information that needs to be conveyed. In this example, we&#8217;re looking at a layer 2\/3 neuron in cortex with in vivo two photon imaging. The maximum projection looks very good, but if there was more noise in the background, then the smart average might have looked better.<\/p>\n<p>What&#8217;s a smart average? It simply adds a thresholding step prior to averaging, so that slices with no signals do not contribute to the projection. Note that in this example, the background of the smart average is much blacker than the regular average projection. In this case, it still looks somewhat low-pass filtered compared to the maximum projection, though. Here&#8217;s the code:<\/p>\n<pre><font size=1>\r\nmacro Smart_Average{\r\n\tstackid=getImageID;\r\n\tno=nSlices;\r\n\tstackname=getTitle;\r\n\trun(\"Duplicate...\", \"title=[dup] duplicate range=1-no\");\r\n\tsetSlice((floor(no\/2)));\r\n\trun(\"Threshold...\");\r\n\twaitForUser(\"Set Threshold then click 'OK'.\");\r\n\tsetBatchMode(true);\r\n\trun(\"Convert to Mask\", \"  black\");\r\n\trun(\"Divide...\", \"value=255 stack\");\r\n\trename(\"divided\");\r\n\tbindupid=getImageID;\r\n\timageCalculator(\"Multiply create stack\", stackid ,bindupid);\r\n\trun(\"Z Project...\", \"start=1 stop=no projection=[Sum Slices]\");\r\n\trename(stackname+\"sum\");\r\n\tsumid=getImageID;\r\n\tsetBatchMode(false);\r\n\tselectImage(bindupid);\/\/closing and renaming actions must occur outside of the batch mode\r\n\tclose();\r\n}\r\n\r\n<\/font>\r\n<\/pre>\n<p>From <a href=\"http:\/\/lists.umn.edu\/cgi-bin\/wa?A2=ind1203&#038;L=confocalmicroscopy&#038;P=17609\">this<\/a> listserv thread. Smart average code by G. MacDonald and K. Straatman.<\/p>\n","protected":false},"excerpt":{"rendered":"<p align=\"center\"><a href=\"http:\/\/labrigger.com\/blog\/wp-content\/uploads\/2012\/05\/Comparison.png\"><\/a><\/p>\n<p>To project 3D image stacks to a 2D image, several different algortithms can be used. Maximum projections and averages are the most commonly used. Neither&#8230;<\/p>\n<div class=\"read-more\"><a href=\"http:\/\/labrigger.com\/blog\/2012\/05\/29\/z-projections\/\">Read More<\/a><\/div><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,3],"tags":[21],"class_list":["post-2396","post","type-post","status-publish","format-standard","hentry","category-software","category-tips","tag-imaging"],"_links":{"self":[{"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/posts\/2396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/comments?post=2396"}],"version-history":[{"count":3,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/posts\/2396\/revisions"}],"predecessor-version":[{"id":2401,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/posts\/2396\/revisions\/2401"}],"wp:attachment":[{"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/media?parent=2396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/categories?post=2396"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/labrigger.com\/blog\/wp-json\/wp\/v2\/tags?post=2396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}