{"id":471,"date":"2017-09-11T07:24:24","date_gmt":"2017-09-11T06:24:24","guid":{"rendered":"http:\/\/www.billconnelly.net\/?p=471"},"modified":"2025-07-05T04:15:09","modified_gmt":"2025-07-05T03:15:09","slug":"merging-rois-in-suite2p","status":"publish","type":"post","link":"https:\/\/www.billconnelly.net\/?p=471","title":{"rendered":"Merging ROIs in suite2p"},"content":{"rendered":"<p><a href=\"http:\/\/www.biorxiv.org\/content\/early\/2016\/06\/30\/061507\">Suite2p <\/a>is a wonderful Matlab toolbox written by <a href=\"https:\/\/twitter.com\/marius10p\">Marius Pachitariu<\/a> for analyzing population calcium imaging data. It uses a number of computational tricks to automate and accelerate the process (so no more drawing regions of interest (ROIs) by hand!). However, I spend most of my time imaging dendrites and axons, and here suite2p has a problem. Suite2p uses a heuristic that is looking for approximately elliptical ROIs, and hence it tends to split axons\/dendrites into a large number smaller ROIs. The problem was simple: how can we merge the ROIs belonging to single cells? Well I used the logic that ROIs that belong to the same neuron should have highly correlated calcium signals (yes, I can imagine a situations where this wont be the case in dendrites, but bAPs will still dominate the calcium trace 99.9% of the time). Hence I simply correlate each ROI with every other ROI. ROIs with a correlation coefficient above some user settable threshold are considered to be part of the same process.<\/p>\n<p>The main script is available <a href=\"http:\/\/www.billconnelly.net\/scripts\/join_axon.m\">here<\/a>, and it requires <a href=\"http:\/\/au.mathworks.com\/matlabcentral\/fileexchange\/29702-generate-maximally-perceptually-distinct-colors\">distinguishable_colors.m<\/a> (which in turn requires the image processing toolbox I believe).<\/p>\n<p><a href=\"http:\/\/www.billconnelly.net\/wp-content\/uploads\/2017\/09\/join_axon.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.billconnelly.net\/wp-content\/uploads\/2017\/09\/join_axon-1024x390.png\" alt=\"join_axon\" width=\"680\" height=\"259\" class=\"aligncenter size-large wp-image-472\" srcset=\"https:\/\/www.billconnelly.net\/wp-content\/uploads\/2017\/09\/join_axon-1024x390.png 1024w, https:\/\/www.billconnelly.net\/wp-content\/uploads\/2017\/09\/join_axon-300x114.png 300w, https:\/\/www.billconnelly.net\/wp-content\/uploads\/2017\/09\/join_axon-1380x526.png 1380w, https:\/\/www.billconnelly.net\/wp-content\/uploads\/2017\/09\/join_axon.png 1817w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>The code is relatively well documented\/commented, and there is even a &#8216;Help!&#8217; button. If anyone has any problems with it, please let me know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Suite2p is a wonderful Matlab toolbox written by Marius Pachitariu for analyzing population calcium imaging data. It uses a number of computational tricks to automate and accelerate the process (so no more drawing regions of interest (ROIs) by hand!). However, I spend most of my time imaging dendrites and axons, and here suite2p has a&hellip;<a href=\"https:\/\/www.billconnelly.net\/?p=471\">Read more <span class=\"screen-reader-text\">Merging ROIs in suite2p<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4,12,7,3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/posts\/471"}],"collection":[{"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=471"}],"version-history":[{"count":3,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/posts\/471\/revisions"}],"predecessor-version":[{"id":656,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/posts\/471\/revisions\/656"}],"wp:attachment":[{"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}