hi,
I'm new, so please forgive me if this is a stupid question: I want to translate a stack of images so that the first image is moved n pixels in the X direction, the second moved 2n pixels, the third 3n pixels and so on.. the tool image>transform>translate does exactly what I need, but each of my experiments contains >1000 images in a stack, so doing it manually for each image isn't really an option.. I don't need any fancy content based registration, only a simple progressive linear movement of each slice where I can specify how many pixels the images will be moved per slice. any ideas much appreciated! arvid |
Hi Arvid,
The little macro below should do the trick. In ImageJ, just open a text window and paste into the window. In Fiji, open a new Script, select ImageJ macro as the language and paste the text into the window. Edit the xTranslate and yTranslate as necessary. Open your stack and Run Macro. FYI, if you go to Plugins>Macros>Record, you can find the commands to run ImageJ's functions and put these into a simple macro. For your purposes, it just needed to be put into a loop to run through the stack and edited to use n, 2n, 3n, etc. George //Stack needs to be open xTranslate=1; yTranslate=0; /*Translate a stack of images so that the first image is moved n pixels in the X direction, the second moved 2n pixels, the third 3n pixels and so on.. the variable "n" is represented by xTranslate and yTranslate */ for(i=1;i<=nSlices;i++){ setSlice(i); run("Translate...", "x="+i*xTranslate+" y="+i*yTranslate+" interpolation=None slice"); } On Mon, Nov 4, 2013 at 6:17 PM, rosteu <[hidden email]> wrote: > hi, > I'm new, so please forgive me if this is a stupid question: > > I want to translate a stack of images so that the first image is moved n > pixels in the X direction, the second moved 2n pixels, the third 3n pixels > and so on.. > > the tool image>transform>translate does exactly what I need, but each of my > experiments contains >1000 images in a stack, so doing it manually for each > image isn't really an option.. > I don't need any fancy content based registration, only a simple > progressive > linear movement of each slice where I can specify how many pixels the > images > will be moved per slice. > > any ideas much appreciated! > arvid > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/linear-translation-of-stack-tp5005448.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank you so much George, I haven't gotten it to work yet, but I'm trying to figure it out - it's exactly what I need! /Arvid
On Tue, Nov 5, 2013 at 5:05 PM, George Patterson-2 [via ImageJ] <[hidden email]> wrote: Hi Arvid, |
Hi Arvid,
What's the problem/error? I ran a quick little test on a stack of ~100 images before sending and I thought it worked fine. George On Tue, Nov 5, 2013 at 2:56 PM, rosteu <[hidden email]> wrote: > Thank you so much George, I haven't gotten it to work yet, but I'm trying > to figure it out - it's exactly what I need! > /Arvid > > > On Tue, Nov 5, 2013 at 5:05 PM, George Patterson-2 [via ImageJ] < > [hidden email]> wrote: > > > Hi Arvid, > > The little macro below should do the trick. > > In ImageJ, just open a text window and paste into the window. In Fiji, > > open a new Script, select ImageJ macro as the language and paste the text > > into the window. > > Edit the xTranslate and yTranslate as necessary. Open your stack and Run > > Macro. > > FYI, if you go to Plugins>Macros>Record, you can find the commands to run > > ImageJ's functions and put these into a simple macro. For your purposes, > > it just needed to be put into a loop to run through the stack and edited > > to > > use n, 2n, 3n, etc. > > George > > > > > > > > //Stack needs to be open > > > > xTranslate=1; > > yTranslate=0; > > /*Translate a stack of images so that the first image is moved n > > pixels in the X direction, the second moved 2n pixels, the third 3n > pixels > > and so on.. > > the variable "n" is represented by xTranslate and yTranslate > > */ > > > > > > for(i=1;i<=nSlices;i++){ > > setSlice(i); > > run("Translate...", "x="+i*xTranslate+" y="+i*yTranslate+" > > interpolation=None slice"); > > } > > > > > > > > > > On Mon, Nov 4, 2013 at 6:17 PM, rosteu <[hidden email]< > http://user/SendEmail.jtp?type=node&node=5005453&i=0>> > > wrote: > > > > > hi, > > > I'm new, so please forgive me if this is a stupid question: > > > > > > I want to translate a stack of images so that the first image is moved > n > > > pixels in the X direction, the second moved 2n pixels, the third 3n > > pixels > > > and so on.. > > > > > > the tool image>transform>translate does exactly what I need, but each > of > > my > > > experiments contains >1000 images in a stack, so doing it manually for > > each > > > image isn't really an option.. > > > I don't need any fancy content based registration, only a simple > > > progressive > > > linear movement of each slice where I can specify how many pixels the > > > images > > > will be moved per slice. > > > > > > any ideas much appreciated! > > > arvid > > > > > > > > > > > > -- > > > View this message in context: > > > > > > http://imagej.1557.x6.nabble.com/linear-translation-of-stack-tp5005448.html > > > Sent from the ImageJ mailing list archive at Nabble.com. > > > > > > -- > > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > > > ------------------------------ > > If you reply to this email, your message will be added to the discussion > > below: > > > > > http://imagej.1557.x6.nabble.com/linear-translation-of-stack-tp5005448p5005453.html > > To unsubscribe from linear translation of stack, click here< > > > > . > > NAML< > http://imagej.1557.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml > > > > > > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/linear-translation-of-stack-tp5005448p5005459.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
hi again, thanks for a quick response, I'm suspecting that I might have installed the macro in the wrong way or something, when I run it I get: ')' expected in line 13 <interpolation> = none slice ");" and no translation of my stack of about ~100 images (2x1k pixels). the debug window says: FreeMemory() 496MB of 14991MB (3%) nImages() 1 getTitle() "tif" xTranslate 1 yTtranslate 0 i 1
I didn't want to ask about it until I read up a bit on macros to see if I did something wrong, but now that you asked, this is as far as I've gotten.. (I'm using FIJI (ImageJ 1.48a) and Java 1.6.0_65 (64-bit) on a macbook pro running OS X 10.9)
/arvid On Tue, Nov 5, 2013 at 9:10 PM, George Patterson-2 [via ImageJ] <[hidden email]> wrote: Hi Arvid, |
In reply to this post by George Patterson
ok, solved it - when I copied and pasted the code I got a line break with an extra space - when I removed it the macro worked fine! Thanks again, I'll send you a copy of some images when I'm done!
/Arvid On Tue, Nov 5, 2013 at 11:19 PM, <[hidden email]> wrote:
|
In reply to this post by rosteu
Hi Arvid,
this is a usual problem in this mailing list: The mailer has introduced a line break in a long line. ImageJ macro statements cannot extend over multiple lines, however. The following should be one line (I write it as one line, but the mailer may introduce a line break again...) run("Translate...", "x="+i*xTranslate+" y="+i*yTranslate+" interpolation=None slice"); Please note that there should be a space between the quotes and the word interpolation. Michael ________________________________________________________________ On Nov 5, 2013, at 23:20, rosteu wrote: > hi again, > > thanks for a quick response, I'm suspecting that I might have installed the > macro in the wrong way or something, when I run it I get: > > ')' expected in line 13 > <interpolation> = none slice ");" > > and no translation of my stack of about ~100 images (2x1k pixels). > > the debug window says: > > FreeMemory() 496MB of 14991MB (3%) > nImages() 1 > getTitle() "tif" > xTranslate 1 > yTtranslate 0 > i 1 > > I didn't want to ask about it until I read up a bit on macros to see if I > did something wrong, but now that you asked, this is as far as I've gotten.. > > (I'm using FIJI (ImageJ 1.48a) and Java 1.6.0_65 (64-bit) on a macbook pro > running OS X 10.9) > > /arvid > > > On Tue, Nov 5, 2013 at 9:10 PM, George Patterson-2 [via ImageJ] < > [hidden email]> wrote: > >> Hi Arvid, >> What's the problem/error? >> I ran a quick little test on a stack of ~100 images before sending and I >> thought it worked fine. >> George >> >> >> On Tue, Nov 5, 2013 at 2:56 PM, rosteu <[hidden email]<http://user/SendEmail.jtp?type=node&node=5005460&i=0>> >> wrote: >> >>> Thank you so much George, I haven't gotten it to work yet, but I'm >> trying >>> to figure it out - it's exactly what I need! >>> /Arvid >>> >>> >>> On Tue, Nov 5, 2013 at 5:05 PM, George Patterson-2 [via ImageJ] < >>> [hidden email] <http://user/SendEmail.jtp?type=node&node=5005460&i=1>> >> wrote: >>> >>>> Hi Arvid, >>>> The little macro below should do the trick. >>>> In ImageJ, just open a text window and paste into the window. In >> Fiji, >>>> open a new Script, select ImageJ macro as the language and paste the >> text >>>> into the window. >>>> Edit the xTranslate and yTranslate as necessary. Open your stack and >> Run >>>> Macro. >>>> FYI, if you go to Plugins>Macros>Record, you can find the commands to >> run >>>> ImageJ's functions and put these into a simple macro. For your >> purposes, >>>> it just needed to be put into a loop to run through the stack and >> edited >>>> to >>>> use n, 2n, 3n, etc. >>>> George >>>> >>>> >>>> >>>> //Stack needs to be open >>>> >>>> xTranslate=1; >>>> yTranslate=0; >>>> /*Translate a stack of images so that the first image is moved n >>>> pixels in the X direction, the second moved 2n pixels, the third 3n >>> pixels >>>> and so on.. >>>> the variable "n" is represented by xTranslate and yTranslate >>>> */ >>>> >>>> >>>> for(i=1;i<=nSlices;i++){ >>>> setSlice(i); >>>> run("Translate...", "x="+i*xTranslate+" y="+i*yTranslate+" >>>> interpolation=None slice"); >>>> } >>>> >>>> >>>> >>>> >>>> On Mon, Nov 4, 2013 at 6:17 PM, rosteu <[hidden email]< >>> http://user/SendEmail.jtp?type=node&node=5005453&i=0>> >>>> wrote: >>>> >>>>> hi, >>>>> I'm new, so please forgive me if this is a stupid question: >>>>> >>>>> I want to translate a stack of images so that the first image is >> moved >>> n >>>>> pixels in the X direction, the second moved 2n pixels, the third 3n >>>> pixels >>>>> and so on.. >>>>> >>>>> the tool image>transform>translate does exactly what I need, but >> each >>> of >>>> my >>>>> experiments contains >1000 images in a stack, so doing it manually >> for >>>> each >>>>> image isn't really an option.. >>>>> I don't need any fancy content based registration, only a simple >>>>> progressive >>>>> linear movement of each slice where I can specify how many pixels >> the >>>>> images >>>>> will be moved per slice. >>>>> >>>>> any ideas much appreciated! >>>>> arvid >>>>> >>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Arvid,
Michael's assessment is correct. Sorry I didn't pay enough attention to the text as it was posted. Hope it works for you now. George On Wed, Nov 6, 2013 at 3:56 AM, Michael Schmid <[hidden email]>wrote: > Hi Arvid, > > this is a usual problem in this mailing list: The mailer has introduced a > line break in a long line. ImageJ macro statements cannot extend over > multiple lines, however. > The following should be one line (I write it as one line, but the mailer > may introduce a line break again...) > run("Translate...", "x="+i*xTranslate+" y="+i*yTranslate+" > interpolation=None slice"); > > Please note that there should be a space between the quotes and the word > interpolation. > > Michael > ________________________________________________________________ > On Nov 5, 2013, at 23:20, rosteu wrote: > > > hi again, > > > > thanks for a quick response, I'm suspecting that I might have installed > the > > macro in the wrong way or something, when I run it I get: > > > > ')' expected in line 13 > > <interpolation> = none slice ");" > > > > and no translation of my stack of about ~100 images (2x1k pixels). > > > > the debug window says: > > > > FreeMemory() 496MB of 14991MB (3%) > > nImages() 1 > > getTitle() "tif" > > xTranslate 1 > > yTtranslate 0 > > i 1 > > > > I didn't want to ask about it until I read up a bit on macros to see if I > > did something wrong, but now that you asked, this is as far as I've > gotten.. > > > > (I'm using FIJI (ImageJ 1.48a) and Java 1.6.0_65 (64-bit) on a macbook > pro > > running OS X 10.9) > > > > /arvid > > > > > > On Tue, Nov 5, 2013 at 9:10 PM, George Patterson-2 [via ImageJ] < > > [hidden email]> wrote: > > > >> Hi Arvid, > >> What's the problem/error? > >> I ran a quick little test on a stack of ~100 images before sending and I > >> thought it worked fine. > >> George > >> > >> > >> On Tue, Nov 5, 2013 at 2:56 PM, rosteu <[hidden email]< > http://user/SendEmail.jtp?type=node&node=5005460&i=0>> > >> wrote: > >> > >>> Thank you so much George, I haven't gotten it to work yet, but I'm > >> trying > >>> to figure it out - it's exactly what I need! > >>> /Arvid > >>> > >>> > >>> On Tue, Nov 5, 2013 at 5:05 PM, George Patterson-2 [via ImageJ] < > >>> [hidden email] <http://user/SendEmail.jtp?type=node&node=5005460&i=1>> > >> wrote: > >>> > >>>> Hi Arvid, > >>>> The little macro below should do the trick. > >>>> In ImageJ, just open a text window and paste into the window. In > >> Fiji, > >>>> open a new Script, select ImageJ macro as the language and paste the > >> text > >>>> into the window. > >>>> Edit the xTranslate and yTranslate as necessary. Open your stack and > >> Run > >>>> Macro. > >>>> FYI, if you go to Plugins>Macros>Record, you can find the commands to > >> run > >>>> ImageJ's functions and put these into a simple macro. For your > >> purposes, > >>>> it just needed to be put into a loop to run through the stack and > >> edited > >>>> to > >>>> use n, 2n, 3n, etc. > >>>> George > >>>> > >>>> > >>>> > >>>> //Stack needs to be open > >>>> > >>>> xTranslate=1; > >>>> yTranslate=0; > >>>> /*Translate a stack of images so that the first image is moved n > >>>> pixels in the X direction, the second moved 2n pixels, the third 3n > >>> pixels > >>>> and so on.. > >>>> the variable "n" is represented by xTranslate and yTranslate > >>>> */ > >>>> > >>>> > >>>> for(i=1;i<=nSlices;i++){ > >>>> setSlice(i); > >>>> run("Translate...", "x="+i*xTranslate+" y="+i*yTranslate+" > >>>> interpolation=None slice"); > >>>> } > >>>> > >>>> > >>>> > >>>> > >>>> On Mon, Nov 4, 2013 at 6:17 PM, rosteu <[hidden email]< > >>> http://user/SendEmail.jtp?type=node&node=5005453&i=0>> > >>>> wrote: > >>>> > >>>>> hi, > >>>>> I'm new, so please forgive me if this is a stupid question: > >>>>> > >>>>> I want to translate a stack of images so that the first image is > >> moved > >>> n > >>>>> pixels in the X direction, the second moved 2n pixels, the third 3n > >>>> pixels > >>>>> and so on.. > >>>>> > >>>>> the tool image>transform>translate does exactly what I need, but > >> each > >>> of > >>>> my > >>>>> experiments contains >1000 images in a stack, so doing it manually > >> for > >>>> each > >>>>> image isn't really an option.. > >>>>> I don't need any fancy content based registration, only a simple > >>>>> progressive > >>>>> linear movement of each slice where I can specify how many pixels > >> the > >>>>> images > >>>>> will be moved per slice. > >>>>> > >>>>> any ideas much appreciated! > >>>>> arvid > >>>>> > >>>>> > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by George Patterson
Dear all,
I´m a novice, and I have a problem similar to Arvids post from last year: http://imagej.1557.x6.nabble.com/linear-translation-of-stack-td5005448.html However, I cannot process the image stack using this script without losing the names of the individual tiff files. I want to keep the file names, so I can later process them with a piece of software which relies on a specific code for frame, level and channel number given by the file name. The file names look like this: X####L##C# Where X#### specifies the frame, L## specifies the level and C# specifies the channel. I have 750 frames, 40 lavels and 2 channels in the data set. Are there ways to process Images in a vitual stack, but export them as a tiff-series with the original file names? Or, as an alternative, can the script posted by George be modified to work as a batch operation for a folder? I´d be grateful for any ideas, Günther |
Free forum by Nabble | Edit this page |