Hi,

    I have my own image registration tool that I’ve created on my own local instance of galaxy.

 

The method takes in two images (*.nii.gz) formats and registers them together, and produces one registered *.nii.gz file and a *.trsf matrix file.

 

The first issue encountered was the method was expecting *.nii.gz files as inputs but was receiving *.dat files. I navigated around this problem as shown by the files below:

 

- <<tool id="RegisterAliBabaAffine" name="RegisterAffine">

  <  <description>two images</description>

  <  <command interpreter="bash">$__root_dir__/tools/registration/reg-wrapper.sh $moving $fixed $outputTRSF $outputImage</command>

- <  <inputs>

  <    <param format="binary" name="moving" type="data" label="Moving Image" />

  <    <param format="binary" name="fixed" type="data" label="Fixed Image" />

  <    <param type="hidden" name="outputTRSF" value="output.trsf" label="trsf file" help="Output File must have .trsf extension" />

  <    <param type="hidden" name="outputImage" value="output.nii.gz" label="Image output file" help="Output Image File must have .nii.gz extension" />

   </inputs>

- <  <outputs>

  <    <data format="input" name="output_TRSF" from_work_dir="output.trsf" />

  <    <data format="input" name="output_Image" from_work_dir="output.nii.gz" />

   </outputs>

  <  <help>This tool uses Affine Registration to register two images.</help>

  </tool>

 

#!/bin/bash

MOVING=`mktemp --suffix .nii.gz`

FIXED=`mktemp --suffix .nii.gz`

cat $1 > $MOVING

cat $2 > $FIXED

/usr/local/MILXView.12.08.1/BashScripts/RegisterAliBabaAffine -m $MOVING -f $FIXED -t $3 -o $4

RC=$?

if [[ $RC == 0 ]]; then

  OUTPUTTRSF=`mktemp --suffix .trsf`

  OUTPUTIMG=`mktemp --suffix .nii.gz`

  cat  $OUTPUTTRSF > $3

  cat  $OUTPUTIMG > $4

  rm $OUTPUTTRSF

  rm $OUTPUTIMG

fi

 

rm $MOVING

rm $FIXED

 

exit $RC

 

This allows them to pass the *.nii.gz files that the registration method is expecting.

 

Everything works fine and I can see output generated in the job_working_dir and the history turns green...

 

galaxy@bmladmin-OptiPlex-745:~$ ls -lrt ~/galaxy-dist/database/job_working_directory/000/27/

total 2940

-rw------- 1 galaxy nogroup       0 Sep 13 10:15 tmpRfHsOP_stderr

-rw-r--r-- 1 galaxy nogroup     241 Sep 13 10:35 output.trsf

-rw------- 1 galaxy nogroup      80 Sep 13 10:35 tmplmK0V2_stdout

-rw-r--r-- 1 galaxy nogroup 2998272 Sep 13 10:38 output.nii.gz

 

However, the problem occurs when the files are copied from ~/galaxy-dist/database/job_working_directory/000/27/ to ~/galaxy-dist/database/files/000/. When this happens the files become size = 0.

 

Any ideas?

 

-rw-r--r-- 1 galaxy nogroup       0 Sep 13 09:36 /home/galaxy/galaxy-dist/database/files/000/dataset_40.dat

-rw-r--r-- 1 galaxy nogroup       0 Sep 13 09:36 /home/galaxy/galaxy-dist/database/files/000/dataset_41.dat

-rw-r--r-- 1 galaxy nogroup       0 Sep 13 10:38 /home/galaxy/galaxy-dist/database/files/000/dataset_43.dat

-rw-r--r-- 1 galaxy nogroup       0 Sep 13 10:38 /home/galaxy/galaxy-dist/database/files/000/dataset_42.dat

 

 

The output in galaxy.log indicates it is successful:

 

/home/galaxy/galaxy-dist/tools/registration/reg-wrapper.sh /home/galaxy/galaxy-dist/database/files/000/dataset_23.dat /home/galaxy/galaxy-dist/database/files/000/dataset_20.dat output.trsf output.nii.gz galaxy.jobs DEBUG 2012-09-13 10:38:10,334 The tool did not define exit code or stdio handling; checking stderr for success galaxy.jobs DEBUG 2012-09-13 10:38:10,361 finish(): Moved /home/galaxy/galaxy-dist/database/job_working_directory/000/27/output.trsf to /home/galaxy/galaxy-dist/database/files/000/dataset_42.dat as directed by from_work_dir galaxy.jobs DEBUG 2012-09-13 10:38:10,380 finish(): Moved /home/galaxy/galaxy-dist/database/job_working_directory/000/27/output.nii.gz to /home/galaxy/galaxy-dist/database/files/000/dataset_43.dat as directed by from_work_dir galaxy.jobs DEBUG 2012-09-13 10:38:10,609 job 27 ended

 

Is the issue copying *.nii.gz files and *.trsf file into *.dat files? Anyway around this?

 

I’ve also modified ~/galaxy-dist/lib/galaxy/jobs/__init__.py (line 363) to change shutil.move

 

To shutil.copy2 (same results)

 

Also put in a different output path to copy to. But essentially we have files with size in ~/galaxy-dist/database/job_working_directory/000/id/, but they files are size  0 after the move into ~/galaxy-dist/database/files/000

 

 

Thanks

 

Neil