HolyLab / ImagineInterface.jl

Read and write Imagine analog and digital recordings and commands
Other
2 stars 2 forks source link

Image size for Validation #66

Closed HaoyangRong closed 6 years ago

HaoyangRong commented 6 years ago

Hi Cody, this is more of a question than an issue. When ImagineInterface validates the signal, does it consider the image size? For example, I always use cropped frames that are much smaller than the original one. So theoretically, it should allow more slices to be captured within a stack with a given time length, assuming the piezo is able to keep up. But I often get an error from the validation, saying the two camera pulses are too close to each other, though I need exactly that one or two extra slices to capture the whole brain structure. My assumption is that the validation uses the maximum image size for validation, which caused that problem. But I'm not sure... Any thoughts?

Cody-G commented 6 years ago

Oh yes, you're correct that it's using the maximum image size for validation. The culprit is this line:

https://github.com/HolyLab/ImagineInterface/blob/master/src/validate_single.jl#L154

This was accidental; I intended to just issue a warning when that happens as you can see in this comment:

https://github.com/HolyLab/ImagineInterface/blob/master/src/validate_single.jl#L4

I think we should just change the first line from an error to a warning. Sorry about that, I didn't notice this since I've been disabling validation lately.

HaoyangRong commented 6 years ago

Thank you!

HaoyangRong commented 6 years ago

I found this function in my code for generating waveforms, which checks the image size:

function get_min_exp(ver_bot::Int=chip_size(rig)[2])
  hmax, vmax = chip_size(rig)
  ver_top=vmax-ver_bot
  vert=(ver_bot,ver_top)
  vsize=maximum(vert)-minimum(vert)
  hsize=1000 # Horizontal size doesn't affect camera speed with current cameras. So I set a random value.
  max_fr=max_framerate(rig,hsize,vsize)
  min_exp=1.0/max_fr
  return min_exp
end 

Usage example:

ver_bot=650
min_exp=get_min_exp(ver_bot)
if exp_time<min_exp
    warn(string("Exposure time: ",exp_time," must be greater than ",min_exp," with this bin size."))
end

ver_bot means the truncated pixel number from the bottom in the vertical direction. I don't remember whether I wrote that function or I got it from your package. Anyway, if it helps, may be you can plug it into your validation code :)