Skip to content

Add my experience#42

Merged
mdhe1248 merged 14 commits into
masterfrom
mdhe1248-patch-1
Sep 18, 2017
Merged

Add my experience#42
mdhe1248 merged 14 commits into
masterfrom
mdhe1248-patch-1

Conversation

@mdhe1248
Copy link
Copy Markdown
Contributor

I didn't include any function or script. Should I? I thought my script or functions were not suitable for this page.

I didn't include any function or script. Should I? I thought my script or functions were not suitable for this page.
Copy link
Copy Markdown
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it!

Comment thread README.md
sigmahp = Float64[sigma/x for x in ps] #Highpass filter
sigmalp = [3, 3, 0] #Lowpass filter
λ = 1e-4

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe show the function call that these parameters are used in?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was redundant with the example above. I will add function calls sometime soon and see if it is informative.

Comment thread README.md Outdated
1. Choose good images for registration:
I selected images that do not show evoked calcium activity. There are still spontaneous activity.

2. Median or quantile filtering across time:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of the images or something else?

Copy link
Copy Markdown
Contributor Author

@mdhe1248 mdhe1248 Sep 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't use median filter in Images. This is because I didn't filter across entire time. For example, if I think stacks at around t = 30 and t = 60 are good, I median filtered stacks at t = 27:33 and t = 57:63, respectively. However, running median filter across entire time should be okay. It may take longer time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mean the Images package, I meant "please clarify whether you're median-filtering the raw data or the deformation that comes from registration."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I will clarify that.
I thought having images with less noise might give better results on mismatch calculation. Is this mathematically the same as medial-filtering the deformation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not. I'm not sure which would be better. But reducing noise to the point that pixels are meaningful is a good idea. Another approach would be to use restrict and work with smaller images, since restrict performs averaging and hence also reduces noise.

Comment thread README.md Outdated
This is to reduce noise and spontaneous activity.

3. Replace too high intensity pixels with NaN:
Sometimes, I observed high-intensity objects moving around tissue surface. While these things could be biologically important features, this is disastrous for registration. I ended up with replacing high intensity object (or pixels) with NaN.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually in specific regions, or automatically based purely on intensity? Meaning, was it just img[img .> thresh] = NaN?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It was just img[img .> thresh] = NaN
I wonder replacing many pixels with NaN will still be fine. I also wonder how block moves if entire pixels are NaN.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are checks for this, hopefully it should work as long as there are still some informative blocks.

Comment thread README.md Outdated
algorithm = Apertures[Apertures(fixed, knots, mxshift, λ, pp; pid=wpids[i], correctbias=false) for i = 1:length(wpids)] #Notice that correctbias = false

#### In warping step,
ϕ_s = medfilt(griddeformations(u, knots), 1) #Basically there is no filtering. Notice the input parameter is 1.
Copy link
Copy Markdown
Contributor Author

@mdhe1248 mdhe1248 Sep 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ϕ_s1 = medfilt(griddeformations(u, knots), 1)
ϕ_s2 = griddeformations(u, knots) 
isequal(ϕ_s1, ϕ_s2) # this gives `false` 

#However, 
[isequal(ϕ_s1[i].u, ϕ_s2[i].u) for i in eachindex(ϕ_s1)] # returns trues
[isequal(ϕ_s1[i].knots, ϕ_s2[i].knots) for i in eachindex(ϕ_s1)]  # returns trues

#Actually,
ϕ_s3 = griddeformations(u, knots) 
isequal(ϕ_s2,  ϕ_s3) # this returns false!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`mappedarray` is used for intensity cut.
Comment thread README.md Outdated
#### 3. High intensity thresholding
img0 = load("exp1_med.imagine") #Load the filtered image
img1 = mappedarray(val -> val > 140 ? NaN : val, img0); # Replace high intensity pixels with NaN. 140 is a threshold. NaN is a value for replacement.
img1 = AxisArray(img1, (:x, :l, :z, :time), (0.5770μm, 0.5770μm, 5μm, 2s)); # Assign axes again.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite img0 has axis information, axis should be re-definition for img1 for the downstream process. e.g.) timeaxis(img1) returns nothing. Is there good ways to copy axes from other image?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been noticing this as a problem too. The manual approach would be

img1 = AxisArray(mappedarray(f, img0.data), axes(img0))

But I've even been considering making mappedarray do this automatically. At the moment I'm holding back, though (any time you don't do the "obvious" thing it's a little bit scary), and looking for an idea for how to make the order of wrappers more easily controlled by the user.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.
I will just replace two lines of my script with your manual approach.

Comment thread README.md
tindex0 = [20; stimidx; nimages(img0)-50] #this will be used for registration

#### 2. Temporal median filtering (Run only one time)
tmedian_filter(Float32, "exp1_med.cam", img0, collect(-3:3), tindex0) #in Jerry_RegisterUtils; See `?tmedian_filter`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use mappedarray here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, mappedarray operates element-by-element. You could write a different type if you wanted. (See the code for MappedArrays, it is almost trivial.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably use this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will stick to my code for now; I will just comment StreamingContainer in my script.

@mdhe1248 mdhe1248 merged commit 7eb4241 into master Sep 18, 2017
@timholy timholy deleted the mdhe1248-patch-1 branch February 13, 2020 09:48
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

Successfully merging this pull request may close these issues.

2 participants