[Neuroimaging] SpaceTimeRealigner doesn't write multiple output files

Katie Surrence katiesurrence at gmail.com
Wed Oct 7 18:36:45 CEST 2015


Dear All,

I'm reposting this question from Neurostars to see if anyone here might
have insight.

I'm trying to use SpaceTimeRealigner through NiPype.  I had
SpaceTimeRealigner running, but I realized that I was only realigning
within run, and not between them.

Referring to the reference article, it says that it realigns multiple runs
by computing a mean image within run after 4D realignment, realigning those
mean images to each other, and then composing that transform with the
within run transforms.  So far, so good.  In the sample code in that
article, it passes the realigner object multiple runs in a list.

However, now I return to my original confusion (A: two questions about
simultaneous realignment and slice timing in NiPype
<https://neurostars.org/p/3423/#3428>) about how/where files are written.
When I run SpaceTimeRealigner, the output corr_4D.nii.gz is written to the
current working directory.  When I was realigning one run at a time, I
could just change the working directory in my script and the corrected file
plopped into the right place.  When I try to realign multiple runs at once,
I can't do that, and the single file I get at the end (written into the
current working directory) has the dimensions of a single run (I imagine
it's the last run realigned) not a bunch of concatenated runs.

Here is what I have right now:


for sub in subjects.keys():
    infiles = []
    for run in subjects[sub]:
        infiles.append(os.path.join(root, sub, 'func', run, '4D.nii'))
    realigner = SpaceTimeRealigner()
    realigner.inputs.in_file = infiles
    realigner.inputs.tr = 2.2
    step = 2.2/34.
    order = [x*step for x in range(0, 34)]
    realigner.inputs.slice_times = order
    realigner.inputs.slice_info = 2
    newdir = os.path.join(root, sub, 'func', run, 'tmp')
    if not os.path.isdir(newdir):
        os.mkdir(newdir)
    os.chdir(newdir)
    res = realigner.run()

How do I get SpaceTimeRealigner to both realign runs with each other, and
write an individual corrected 4d file for each run into a distinct
directory?

Thanks very much for any help you can provide.


Best,

Katie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20151007/b5efc90f/attachment.html>


More information about the Neuroimaging mailing list