Plugin/macro to open directly a 3B reconstruction

Bayesian analysis of blinking and bleaching

Plugin/macro to open directly a 3B reconstruction

Postby morales » Tue Sep 17, 2013 7:03 pm

Hi again!
It is actually quite neat to have the control panel, and is very useful to set the reconstruction blur FWHM to see the effect on each reconstruction. However once I've decided for a certain blur, I was wondering if there was a way to open directly an image file without going trough the control panel. I reckon it would be very useful for a macro that I'm writing which automatically assembles 3B reconstructions of small contiguous ROIs into a larger reconstructed area.

Thanks in advance.
morales
 
Posts: 6
Joined: Tue Jul 23, 2013 1:24 pm

Re: Plugin/macro to open directly a 3B reconstruction

Postby edrosten » Mon Sep 23, 2013 12:39 pm

morales wrote:Hi again!
It is actually quite neat to have the control panel, and is very useful to set the reconstruction blur FWHM to see the effect on each reconstruction. However once I've decided for a certain blur, I was wondering if there was a way to open directly an image file without going trough the control panel.


Such a feature does not currently exist. It looks quite easy to implement. I'll reply to the thread again when it's done.

I reckon it would be very useful for a macro that I'm writing which automatically assembles 3B reconstructions of small contiguous ROIs into a larger reconstructed area.


This should actually be easier. You can simply combine all the runs into one large file by simply pasting them one after another. The result will be loaded and the ROI set appropriately. Note that if they've been run for different amounts of time, then the relative brightnesses will be different, but if they've been run for roughly the same number of iterations, then the reconstruction will be fine.
edrosten
 
Posts: 42
Joined: Wed Jul 18, 2012 2:54 pm

Re: Plugin/macro to open directly a 3B reconstruction

Postby edrosten » Tue Sep 24, 2013 3:45 pm

morales wrote:Hi again!
It is actually quite neat to have the control panel, and is very useful to set the reconstruction blur FWHM to see the effect on each reconstruction. However once I've decided for a certain blur, I was wondering if there was a way to open directly an image file without going trough the control panel.


http://www.coxphysics.com/3b/3B_release ... a10f59977/

I've added that as a feature.

If you go to "Open 3B run", you will see that the new dialog box has options for the initial choice for the reconstruction FWHM and pixel size. If you record a macro to open a 3B run, you will get a line like this:

run("Open 3B run", "open=test.txt pixel=100 fwhm=100 reconstruction=10 show");

if you delete the "show" parameter and run the macro, it will simply export the reconstruction as an image and not show the control panel.

Is this what you had in mind?
edrosten
 
Posts: 42
Joined: Wed Jul 18, 2012 2:54 pm

Re: Plugin/macro to open directly a 3B reconstruction

Postby morales » Thu Sep 26, 2013 6:39 pm

edrosten wrote:This should actually be easier. You can simply combine all the runs into one large file by simply pasting them one after another. The result will be loaded and the ROI set appropriately. Note that if they've been run for different amounts of time, then the relative brightnesses will be different, but if they've been run for roughly the same number of iterations, then the reconstruction will be fine.


Thanks! This feature comes very handy. I don't know why I did not know about it. I only have a question. In the manual it says: "If possible, placing the boundary near a bright region should be avoided. If this is not possible, then the reconstruction close to the boundary should be ignored." When we concatenate the file as you suggest, should we be careful in interpreting any fluorescence coming from pixels close to the boundary of the individual ROIs?

edrosten wrote:run("Open 3B run", "open=test.txt pixel=100 fwhm=100 reconstruction=10 show");
if you delete the "show" parameter and run the macro, it will simply export the reconstruction as an image and not show the control panel.
Is this what you had in mind?


Thank you very much. This is exactly what I had in mind. I'm using round 12x12 pixel ROIs and I can't always have boundaries of the ROI free of fluorescence. Therefore I was thinking I should only take the center of the ROI (6x6) and that is why I cut from the reconstructions and paste them on a stack at its proper location at different slices and z-project the maximum intensity. Hope that makes sense.... Thanks again!
morales
 
Posts: 6
Joined: Tue Jul 23, 2013 1:24 pm

Re: Plugin/macro to open directly a 3B reconstruction

Postby edrosten » Fri Sep 27, 2013 1:30 pm

morales wrote:
edrosten wrote:This should actually be easier. You can simply combine all the runs into one large file by simply pasting them one after another. The result will be loaded and the ROI set appropriately. Note that if they've been run for different amounts of time, then the relative brightnesses will be different, but if they've been run for roughly the same number of iterations, then the reconstruction will be fine.


Thanks! This feature comes very handy. I don't know why I did not know about it. I only have a question. In the manual it says: "If possible, placing the boundary near a bright region should be avoided. If this is not possible, then the reconstruction close to the boundary should be ignored." When we concatenate the file as you suggest, should we be careful in interpreting any fluorescence coming from pixels close to the boundary of the individual ROIs?


That's correct. The best solution is to use ROIs which are too large and then discard any data near the edges. The strategy we use is:
1. Divide the image up into adjacent, non-overlapping squares.
2. For each square, create a ROI which is a bit larger (e.g. 2 pixels). The ROIs will now overlap.
3. After processing each ROI, discard any spots which lie outside it's square.
4. Combine all the results

This will avoid using the area too close to the edge of the ROI and will ensure that there are no gaps or overlaps.

We're hoping to add some features to 3B later to help do this, but we have no immediate plans.
morales wrote:
edrosten wrote:run("Open 3B run", "open=test.txt pixel=100 fwhm=100 reconstruction=10 show");
if you delete the "show" parameter and run the macro, it will simply export the reconstruction as an image and not show the control panel.
Is this what you had in mind?


Thank you very much. This is exactly what I had in mind. I'm using round 12x12 pixel ROIs and I can't always have boundaries of the ROI free of fluorescence. Therefore I was thinking I should only take the center of the ROI (6x6) and that is why I cut from the reconstructions and paste them on a stack at its proper location at different slices and z-project the maximum intensity. Hope that makes sense.... Thanks again!


That's probably an excessive amount of cut out. It will work, but be slower than necessary. For a 12x12 ROI, you could probably use the 8x8 inner square. Good values are 11x11 for the inner one, and 13x13 for the outer one.

Performing a cut, paste and Z project will work. Another alternative is to filter out spots from the data and then do a reconstruction from the filtered data. Let me know if you require any assistance in this regard.

-Ed
edrosten
 
Posts: 42
Joined: Wed Jul 18, 2012 2:54 pm

Re: Plugin/macro to open directly a 3B reconstruction

Postby morales » Mon Oct 14, 2013 9:52 am

edrosten wrote:
Performing a cut, paste and Z project will work. Another alternative is to filter out spots from the data and then do a reconstruction from the filtered data. Let me know if you require any assistance in this regard.

-Ed


Hi!
I reconstructed a whole image by concatenating the files and by cutting and pasting the center. The results are quite different. In the cutting and pasting method I see very define spots and clusters of the signal. These clusters are blurred and appear diffuse in the reconstruction from the concatenated files. Therefore, I would be very interested in learning how to filter spots from the text file to take only the center of the ROI to see if that makes a difference . Although I have to say that the cutting pasting method works very well.Thanks again. It all has been very useful!
morales
 
Posts: 6
Joined: Tue Jul 23, 2013 1:24 pm

Re: Plugin/macro to open directly a 3B reconstruction

Postby edrosten » Fri Nov 01, 2013 5:21 pm

morales wrote:
edrosten wrote:
Performing a cut, paste and Z project will work. Another alternative is to filter out spots from the data and then do a reconstruction from the filtered data. Let me know if you require any assistance in this regard.



Hi!
I reconstructed a whole image by concatenating the files and by cutting and pasting the center. The results are quite different. In the cutting and pasting method I see very define spots and clusters of the signal. These clusters are blurred and appear diffuse in the reconstruction from the concatenated files. Therefore, I would be very interested in learning how to filter spots from the text file to take only the center of the ROI to see if that makes a difference . Although I have to say that the cutting pasting method works very well.Thanks again. It all has been very useful!


My guess would be that the difference in appearance is due to different relative scaling of the different areas.

When it comes to filtering spots, you need to know the format of the file. The format is relatively simple. Each line of the file is a record. There are records of many different types and you can ignore and discard almost all of them.

The important ones are the PIXELS line which records the ROI and the PASSx: lines, which record the results of a pass of the algorithm. The ROIs you just want to pass through unmodified to the plugin viewer.

The PASSx lines are of this format:

PASS1: brightness1 size1 x1 y1 brightness2 size2 x2 y2 ...

You need to filter out points by x and y. You don't need to keep the brightenss and size values since while they're important to the algorithm they are not used by the viewer.

If you put the following code into a file called filter.awk
Code: Select all
/PIXELS/

/PASS.:/{

   printf $1

   for(i=2; i <= NF; i+= 4)
   {
      x=$(i+2)
      y=$(i+3)

      #Filter here
      if(x >= xmin && x <= xmax && y >= ymin && y <= ymax)
      {
         printf(" 1 1 %s %s", x, y)
      }
   }

   print ""
}


You can filter the data by running the following command from the shell:

Code: Select all
awk -v xmin=24 -v xmax=30 -v ymin=25 -v ymax=30 -f filter.awk  original_3b_output.txt > filtered_output.txt


Naturally you'll need to modify the x and y ranges given to match the rectangluar area you want to accept. The vaules are in pixels. 3B considers (0,0) to be the top left pixel of an image (the same as ImageJ).


-Ed
edrosten
 
Posts: 42
Joined: Wed Jul 18, 2012 2:54 pm

Re: Plugin/macro to open directly a 3B reconstruction

Postby morales » Thu Nov 07, 2013 2:02 pm

Thanks! I'll give it a try.
morales
 
Posts: 6
Joined: Tue Jul 23, 2013 1:24 pm

Re: Plugin/macro to open directly a 3B reconstruction

Postby chal.nikkal » Mon Jan 12, 2015 12:59 pm

In the manual it says: "If possible, placing the boundary near a bright region should be avoided. If this is not possible, then the reconstruction close to the boundary should be ignored." When we concatenate the file as you suggest, should we be careful in interpreting any fluorescence coming from pixels close to the boundary of the individual ROIs??
chal.nikkal
 
Posts: 1
Joined: Mon Jan 12, 2015 11:35 am

Re: Plugin/macro to open directly a 3B reconstruction

Postby edrosten » Fri Jan 23, 2015 10:57 am

Yes, in general you need to be very careful about using data near the boundary.

If the region is too large and you cannot avoid the boundary then the solution is to split the region up into a grid of overlapping masks. That way data from near the edge of the mask can be rejected without leaving gaps in the final reconstruction. There are some instructions and programs described here which will help:

viewtopic.php?f=10&t=30218

Note that you'll need one of the beta releases of 3B in order to use this feature.

-Ed
edrosten
 
Posts: 42
Joined: Wed Jul 18, 2012 2:54 pm


Return to 3B

Who is online

Users browsing this forum: No registered users and 0 guests

cron