Ignoring single pixels in ROI activity

176 views
Skip to first unread message

Eirinn Mackay

unread,
May 26, 2016, 5:39:36 AM5/26/16
to Bonsai Users
Hi Goncalo,

I'm measuring activity in many (96) ROIs, using background subtraction -> RoiActivity to get a count of pixel changes between frames. But I want to ignore single pixels (noise). Currently I'm doing a fair hacky method:



Background subtraction -> FindContours (with minarea 1) -> DrawContours -> RoiActivity.

This works but it doesn't seem very efficient since I don't actually care about contours. Is there a simple way to remove single pixels? I couldn't find a Median filter and I'm not sure if Filter2D is what I want.

On a related note, will it be possible to get better tools for generating ROIs? Having to draw 96 boxes by hand is a hassle, and they aren't all the same size. On the plus side, despite these complaints Bonsai is working perfectly for this assay and I can't imagine doing my work without it :)

Cheers,
Eirinn
Auto Generated Inline Image 1

Eirinn Mackay

unread,
May 26, 2016, 7:03:59 AM5/26/16
to Bonsai Users
Oh I just saw there's a Median option in the Smooth transform. What parameters should I set to remove single pixels... 3x3?

Gonçalo Lopes

unread,
May 27, 2016, 12:22:15 PM5/27/16
to Eirinn Mackay, Bonsai Users
Hi Eirinn,

You could actually also use the FindContours with a MinArea and then just sum the total areas of all the contours.

If you prefer to do it in pixel space it might be better to use the MorphologicalOperator node set to "Open". This applies an Erode followed by a Dilate and should be good at getting rid of the single pixel noise. U can tweak the kernel size and number of iterations online to figure out which setting works best for you.

Hope this helps!

From: Eirinn Mackay
Sent: ‎26/‎05/‎2016 12:04
To: Bonsai Users
Subject: [bonsai-users] Re: Ignoring single pixels in ROI activity

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/bonsai-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/e88b475c-079f-4eb3-9293-a00c0b9cfffc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages