Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification on spatialr and se #57

Open
gavinscott280 opened this issue Apr 25, 2021 · 8 comments
Open

Clarification on spatialr and se #57

gavinscott280 opened this issue Apr 25, 2021 · 8 comments

Comments

@gavinscott280
Copy link

Hi Jinghao,

I just wanted to doublecheck that I properly understand how these input parameters work.

I have some miniscope recordings (V4 UCLA miniscope; Labmaker) in which I have measured the mean cell cell radius to be about 5.5 pixels with no downsampling. The way I understand the script and accompanying documentation, the cell size input parameter is a structure element with cell radius in pixels (AFTER spatial downsampling) as the input argument. So when I'm analyzing these recordings in min1pipe, I have been using either 1) spatialr = 1 and se = 5 (or 6), or; 2) spatialr = 0.5 and se = 3.

Could you confirm whether or not this is correct?

Thanks very much!
Gavin

@JinghaoLu
Copy link
Owner

Hi Gavin,

Yes your understanding is correct. However, between the two options you mentioned, the latter is slightly preferred, but in practice, I would use either spatialr = 0.5 and se = 4, or spatialr = 0.75 and se = 5.

So the logic here is 1. whenever you can, it would be better to downsample the video so you will have a much shorter running time; 2. se should be >= 3, and >3 when it is possible; 3. the selection of se contains some flexibility, for example, in your case without downsampling, it would be okay to use se from any integer within [4, 6], therefore even when you downsample, you can still choose a slightly larger se to avoid structure element degeneration (< 3).

@gavinscott280
Copy link
Author

Great, thanks again Jinghao!

@ElhamGhanbarian
Copy link

Hi Jinghao,

Is it possible to run min1pipe with no spatial downsampling (spatialr=1) if the running time is not a concern? Somewhere in your comments, I read that in theory for spatialr=1, se should be equal to 10. But based on your comment above it looks like se should be within [4,6]. My cells are usually 20-25 pixels so maybe se=5 is OK?

Thanks very much,
Elham

@JinghaoLu
Copy link
Owner

Hi @ElhamGhanbarian, yes it is possible to run the code with no spatial downsampling, but in theory no spatial downsampling + large se is the same as spatial downsampling + small se, so why not using quadratically faster option. Plus with a spatial downsampling, you get those small background noise largely removed from the beginning and the algorithm can naturally focus more on the neuron ROIs. Ideally se should be within [3, 7] and the spatialr can be adjusted accordingly. If spatialr = 1 and your cells are 20-25 pixels, then you have to use se = [10, 12].

@ElhamGhanbarian
Copy link

Hi,
I remember that I analyzed a dataset from one mouse with no spatial downsampling and se=5, and got ~600 cells that were all good cells. Then I tried another dataset from the same mouse with spatialr=0.5 and se=5 and got ~300 cells, and when tried with spatialr=0.25 and se= 4 (or 5) got ~150 cells. So I think spatial downsampling losses information in the v4 miniscope recordings probably because cells are, generally, smaller than v3 or Inscopix. Cells range from 10 to 20 pixels in my recent recordings.

@JinghaoLu
Copy link
Owner

Hi @ElhamGhanbarian, the bottom line is you use the typical neuronal radius in pixel as se, and if se is too big, it means you have the wiggle room to spatially downsample the video so that se falls [4, 6]. In your case, since you want to keep as much info as possible, the cutoff radius in pixel you should look at is 10 indeed, therefore se=5 with spatialr=1.

@ElhamGhanbarian
Copy link

Thanks, Jinghao. The problem is that without downsampling it takes more than 15 hours and then usually an error happens. The most recent error that I got was the 'out of memory error' although I have 160GB of RAM and I cropped the original movie to keep the main ROI. So I think downsampling is critical for the algorithm.

@JinghaoLu
Copy link
Owner

@ElhamGhanbarian You are right, so in your case at least you can try spatialr=0.5 and se=3 or 4. It probably is the graphical memory that is limiting the running but not RAM by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants