Hi Paul and thank you for the replay, can you rewrite my code to work as you said? Maybe I don't understand what do you mean. Thank you very very much. 2015-11-19 10:47 GMT+01:00 paul mccarthy <[log in to unmask]>: > Hi Carmine, > > If you want to estimate the transformation in two steps, and then apply > that transformation, you'll need three steps. > > As Eelke suggested, drop the '-applyxfm' and '-out' options from the > seccond step. Then add a third step which uses '-applyxfm' and '-init > output_linear.mat' to produce a registered image. > > Cheers, > > Paul > > On 18 November 2015 at 13:16, Carmine Pagliaro <[log in to unmask]> > wrote: > >> yes, well I cannot use both? >> >> 2015-11-18 14:10 GMT+01:00 Eelke Visser <[log in to unmask]>: >> >>> Hi, >>> >>> Are you trying to refine the registration from step 1 in step 2 by using >>> weighting masks? In that case you should drop the -applyxfm. >>> >>> Cheers, >>> Eelke >>> >>> >>> > On 18 Nov 2015, at 10:25, Carmine Pagliaro <[log in to unmask]> >>> wrote: >>> > >>> > Hi Eelke, >>> > I would estimate a transformation starting from >>> > >>> > flirt -in moving_mask_roi.nii.gz -ref fixed_mask_roi.nii.gz -omat >>> output_init_mask.nii.gz >>> > >>> > then use this matrix to >>> > >>> > flirt -in moving.nii.gz -ref fixed.nii.gz -inweight >>> moving_mask_roi.nii.gz -refweight fixed_mask_roi.nii.gz -omat >>> output_linear.mat -dof 9 -out output_mov_to_fix.nii.gz -init >>> output_init_mask.nii.gz -applyxfm >>> > >>> > so I can improve my registration. >>> > >>> > 2015-11-18 11:13 GMT+01:00 Eelke Visser <[log in to unmask]>: >>> > Hi Carmine, >>> > >>> > That doesn’t look quite right, although I am not completely sure what >>> your intended result is. Your step 2 will apply the registration produced >>> by step 1, but none of the additional options will be used as it is just >>> applying a transformation (rather than searching for an optimal one). Also >>> note that output_init.nii.gz is a text file, not a nifti. >>> > >>> > Could you give some more details about what you want to do? >>> > >>> > Thanks, >>> > Eelke >>> > >>> > >>> > >>> > > On 17 Nov 2015, at 13:49, Carmine Pagliaro < >>> [log in to unmask]> wrote: >>> > > >>> > > Can you check and give me a feedback for this code? >>> > > what a want do is, estimate a transformation matrix with the first >>> step and then pass the transformation matrix to the second step. >>> > > >>> > > 1st step: flirt -ref fixed.nii.gz -in moving.nii.gz -dof 9 >>> -omat output_init.nii.gz >>> > > 2nd step: flirt -in moving.nii.gz -ref fixed.nii.gz -refweight >>> fixed_mask.nii.gz -inweight moving_mask.nii.gz -omat output_linear.mat -dof >>> 9 -out output_mov_to_fix.nii.gz -init output_init.nii.gz -applyxfm >>> > > >>> > > >>> > > thank you >>> > > >>> > > >>> > > 2015-11-17 12:38 GMT+01:00 Carmine Pagliaro < >>> [log in to unmask]>: >>> > > thank you very very much now its work. >>> > > >>> > > 2015-11-17 12:12 GMT+01:00 Matthew Webster < >>> [log in to unmask]>: >>> > > Hello, >>> > > Does >>> > > >>> > > String cmd = "fslstats"; >>> > > ProcessBuilder pb = new ProcessBuilder("bash","-c"," . >>> /etc/fsl/fsl.sh;"+cmd); >>> > > Process p = pb.start(); >>> > > >>> > > work on your system? >>> > > >>> > > Kind Regards >>> > > Matthew >>> > > >>> > >> Map<String, String> env; >>> > >> env = pb.environment(); >>> > >> env.put("FSLDIR", "/usr/lib/fsl/5.0"); >>> > >> env.put("PATH", "/usr/lib/fsl/5.0:$PATH"); >>> > >> env.put("PATH", "$FSLDIR/bin:$PATH"); >>> > >> Process p = pb.start(); >>> > >> something like this? >>> > >> >>> > >> 2015-11-17 11:27 GMT+01:00 paul mccarthy <[log in to unmask]>: >>> > >> Hi Carmine, >>> > >> >>> > >> The exact list of variables and their values will differ on >>> different platforms - it depends on your specific setup. >>> > >> >>> > >> Perhaps a better way would be to use an approach similar to what is >>> suggested here: >>> > >> >>> > >> http://stackoverflow.com/a/18383904 >>> > >> >>> > >> i.e. Set up your FSLDIR and PATH variables using the >>> ProcessBuilder, and then source the fsl.sh script *and* run the command in >>> a single line (and hence in the same shell). >>> > >> >>> > >> Cheers, >>> > >> >>> > >> Paul >>> > >> >>> > >> On 17 November 2015 at 10:18, Carmine Pagliaro < >>> [log in to unmask]> wrote: >>> > >> Thank you Paul. >>> > >> there is a complete list of env that I must set? >>> > >> >>> > >> 2015-11-17 11:00 GMT+01:00 paul mccarthy <[log in to unmask]>: >>> > >> Hi Carmine, >>> > >> >>> > >> All of the FSL commands (with the exception of FSLView) must be run >>> with a specific environment configuyation. For example. the PATH, FSLDIR, >>> and FSLOUTPUTTYPE environment variables must be set to the correct value >>> for the FSL commands to work. The FSL environment is typically configured >>> from your ~/.bashrc, or ~/.profile script, with something like this: >>> > >> >>> > >> export FSLDIR=~/fsl_builds/fsl >>> > >> export PATH=$FSLDIR/bin:$PATH >>> > >> . $FSLDIR/etc/fslconf/fsl.sh >>> > >> >>> > >> >>> > >> Your java program is trying to run a FSL command in an environment >>> that has not been configured to run FSL commands. You have three options: >>> > >> >>> > >> 1. Run your java program from within an environment that has >>> already been configured to use FSL. >>> > >> >>> > >> 2. Get your java program to configure the environment before >>> calling the FSL command (using e.g. the ProcessBuilder class) >>> > >> >>> > >> 3. Create a wrapper script which configures the FSL environment, >>> and then calls the FSL command you wish to use. >>> > >> >>> > >> Cheers, >>> > >> >>> > >> Paul >>> > >> >>> > >> On 17 November 2015 at 08:29, Carmine Pagliaro < >>> [log in to unmask]> wrote: >>> > >> I tried with this >>> > >> cmd2 = "fslinfo test.nii.gz" >>> > >> ProcessBuilder pb = new ProcessBuilder("bash","-l","-c",cmd2); >>> > >> >>> > >> and i obtained this >>> > >> bash: fslinfo: comando non trovato >>> > >> >>> > >> 2015-11-16 17:40 GMT+01:00 Matthew Webster < >>> [log in to unmask]>: >>> > >> Hello, >>> > >> I think the best solution here is to call your fsl >>> commands invoking bash as a login shell, this way your bash_profile should >>> be sourced as normal, e.g. calls along the lines of: >>> > >> >>> > >> ProcessBuilder pb = new ProcessBuilder("bash","-l","-c","fslstats"); >>> > >> >>> > >> Kind Regards >>> > >> Matthew >>> > >> >>> > >>> ok first solved. now i get this error: >>> > >>> >>> > >>> /usr/lib/fsl/5.0/fslinfo: 77: /usr/lib/fsl/5.0/fslinfo: >>> /bin/fslhd: not found >>> > >>> /usr/lib/fsl/5.0/fslinfo: 77: /usr/lib/fsl/5.0/fslinfo: cat: not >>> found >>> > >>> /usr/lib/fsl/5.0/fslinfo: 77: /usr/lib/fsl/5.0/fslinfo: egrep: not >>> found >>> > >>> >>> > >>> 2015-11-16 17:01 GMT+01:00 Carmine Pagliaro < >>> [log in to unmask]>: >>> > >>> thank Paul. in my case it look like this? >>> > >>> >>> > >>> env.put("PATH", env.get("PATH")+"/usr/lib/fsl/5.0"); >>> > >>> >>> > >>> >>> > >>> 2015-11-16 16:52 GMT+01:00 Matthew Webster < >>> [log in to unmask]>: >>> > >>> Hi Carmine, >>> > >>> Paul's email links to a pure-java solution - >>> this should work without needing to modify .bashrc etc. >>> > >>> Kind Regards >>> > >>> Matthew >>> > >>> >>> > >>>> myabe i wrong something. env java command don't show fsl. i >>> restart system too. nothing happens. what else i can do? >>> > >>>> >>> > >>>> 2015-11-16 16:26 GMT+01:00 Matthew Webster < >>> [log in to unmask]>: >>> > >>>> Hello - that looks good, yes. >>> > >>>> >>> > >>>> Kind Regards >>> > >>>> Matthew >>> > >>>> >>> > >>>> >>> > >>>>> Hello Dr. Webster. I can confirm that fsl is not in the java >>> env. so how can I add? >>> > >>>>> something like this: >>> > >>>>> export PATH="/usr/lib/fsl/5.0:$PATH" >>> > >>>>> ? >>> > >>>>> >>> > >>>>> 2015-11-16 16:12 GMT+01:00 Matthew Webster < >>> [log in to unmask]>: >>> > >>>>> Hello, >>> > >>>>> Can you try execing env in your java program, and >>> check to see if /usr/lib/fsl/5.0 is in the output? If not then you might >>> want to add it to your PATH in .bashrc. >>> > >>>>> Kind Regards >>> > >>>>> Matthew >>> > >>>>> >>> > >>>>> >>> > >>>>>> carmine@HpCarmine:~$ which fslinfo >>> > >>>>>> /usr/lib/fsl/5.0/fslinfo >>> > >>>>>> carmine@HpCarmine:~$ which fslview >>> > >>>>>> /usr/bin/fslview >>> > >>>>>> >>> > >>>>>> fsl script are in the /usr/lib/fsl/5.0/ how can i link all the >>> script. i think about a simbolic link it's the correct way? >>> > >>>>>> >>> > >>>>>> 2015-11-16 14:58 GMT+01:00 Matthew Webster < >>> [log in to unmask]>: >>> > >>>>>> Hello Carmine, >>> > >>>>>> I think you need to check that your >>> environment is set up correctly so that the FSL binaries can be located - >>> the error is telling you that java cannot find the fslinfo script. You >>> might want to run the command 'env' to check what environment java is using. >>> > >>>>>> >>> > >>>>>> Kind Regards >>> > >>>>>> Matthew >>> > >>>>>> >>> > >>>>>>> Sorry, i'm under debian 8.0 >>> > >>>>>>> >>> > >>>>>>> 2015-11-16 14:26 GMT+01:00 Carmine Pagliaro < >>> [log in to unmask]>: >>> > >>>>>>> this is the ccode that i use >>> > >>>>>>> String cmd2 = "fslinfo test.nii.gz"; >>> > >>>>>>> Process p = Runtime.getRuntime().exec(cmd2); >>> > >>>>>>> >>> > >>>>>>> BufferedReader stdInput = new BufferedReader(new >>> InputStreamReader(p.getInputStream())); >>> > >>>>>>> >>> > >>>>>>> BufferedReader stdError = new BufferedReader(new >>> InputStreamReader(p.getErrorStream())); >>> > >>>>>>> >>> > >>>>>>> // read the output from the command >>> > >>>>>>> System.out.println("Here is the standard output of >>> the command:\n"); >>> > >>>>>>> while ((s = stdInput.readLine()) != null) { >>> > >>>>>>> System.out.println(s); >>> > >>>>>>> } >>> > >>>>>>> >>> > >>>>>>> // read any errors from the attempted command >>> > >>>>>>> System.out.println("Here is the standard error of >>> the command (if any):\n"); >>> > >>>>>>> while ((s = stdError.readLine()) != null) { >>> > >>>>>>> System.out.println(s); >>> > >>>>>>> } >>> > >>>>>>> >>> > >>>>>>> and thi is the error: >>> > >>>>>>> >>> > >>>>>>> java.io.IOException: Cannot run program "fslinfo": error=2, >>> File o directory non esistente >>> > >>>>>>> >>> > >>>>>>> 2015-11-16 14:01 GMT+01:00 Matthew Webster < >>> [log in to unmask]>: >>> > >>>>>>> Hi Carmine, >>> > >>>>>>> Can you provide a little more >>> information on what is going wrong? Do you get any error messages? >>> > >>>>>>> Kind Regards >>> > >>>>>>> Matthew >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>>> Hi FSL team, >>> > >>>>>>>> I would use FSL command like fslinfo, fslview flirt ecc. in >>> java programm calling the java method: >>> > >>>>>>>> Process p = Runtime.getRuntime().exec(""); >>> > >>>>>>>> this work fine only with fslview command, but with the others >>> not. >>> > >>>>>>>> can anyone help me? >>> > >>>>>>>> >>> > >>>>>>>> thank you >>> > >>>>>>>> >>> > >>>>>>>> >>> > >>>>>>>> -- >>> > >>>>>>>> Carmine Pagliaro >>> > >>>>>>>> Research Fellow Neuroimaging Unit >>> > >>>>>>>> Institute of Bioimaging and Molecular Physiology-CNR >>> > >>>>>>>> Italy >>> > >>>>>>>> Life is for sharing. >>> > >>>>>>>> >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>> -- >>> > >>>>>>> Carmine Pagliaro >>> > >>>>>>> Research Fellow Neuroimaging Unit >>> > >>>>>>> Institute of Bioimaging and Molecular Physiology-CNR >>> > >>>>>>> Italy >>> > >>>>>>> Life is for sharing. >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>> >>> > >>>>>>> -- >>> > >>>>>>> Carmine Pagliaro >>> > >>>>>>> Research Fellow Neuroimaging Unit >>> > >>>>>>> Institute of Bioimaging and Molecular Physiology-CNR >>> > >>>>>>> Italy >>> > >>>>>>> Life is for sharing. >>> > >>>>>>> >>> > >>>>>> >>> > >>>>>> >>> > >>>>>> >>> > >>>>>> >>> > >>>>>> -- >>> > >>>>>> Carmine Pagliaro >>> > >>>>>> Research Fellow Neuroimaging Unit >>> > >>>>>> Institute of Bioimaging and Molecular Physiology-CNR >>> > >>>>>> Italy >>> > >>>>>> Life is for sharing. >>> > >>>>>> >>> > >>>>> >>> > >>>>> >>> > >>>>> >>> > >>>>> >>> > >>>>> -- >>> > >>>>> Carmine Pagliaro >>> > >>>>> Research Fellow Neuroimaging Unit >>> > >>>>> Institute of Bioimaging and Molecular Physiology-CNR >>> > >>>>> Italy >>> > >>>>> Life is for sharing. >>> > >>>>> >>> > >>>> >>> > >>>> >>> > >>>> >>> > >>>> >>> > >>>> -- >>> > >>>> Carmine Pagliaro >>> > >>>> Research Fellow Neuroimaging Unit >>> > >>>> Institute of Bioimaging and Molecular Physiology-CNR >>> > >>>> Italy >>> > >>>> Life is for sharing. >>> > >>>> >>> > >>> >>> > >>> >>> > >>> >>> > >>> >>> > >>> -- >>> > >>> Carmine Pagliaro >>> > >>> Research Fellow Neuroimaging Unit >>> > >>> Institute of Bioimaging and Molecular Physiology-CNR >>> > >>> Italy >>> > >>> Life is for sharing. >>> > >>> >>> > >>> >>> > >>> >>> > >>> >>> > >>> -- >>> > >>> Carmine Pagliaro >>> > >>> Research Fellow Neuroimaging Unit >>> > >>> Institute of Bioimaging and Molecular Physiology-CNR >>> > >>> Italy >>> > >>> Life is for sharing. >>> > >>> >>> > >> >>> > >> >>> > >> >>> > >> >>> > >> -- >>> > >> Carmine Pagliaro >>> > >> Research Fellow Neuroimaging Unit >>> > >> Institute of Bioimaging and Molecular Physiology-CNR >>> > >> Italy >>> > >> Life is for sharing. >>> > >> >>> > >> >>> > >> >>> > >> >>> > >> >>> > >> -- >>> > >> Carmine Pagliaro >>> > >> Research Fellow Neuroimaging Unit >>> > >> Institute of Bioimaging and Molecular Physiology-CNR >>> > >> Italy >>> > >> Life is for sharing. >>> > >> >>> > >> >>> > >> >>> > >> >>> > >> >>> > >> -- >>> > >> Carmine Pagliaro >>> > >> Research Fellow Neuroimaging Unit >>> > >> Institute of Bioimaging and Molecular Physiology-CNR >>> > >> Italy >>> > >> Life is for sharing. >>> > >> >>> > > >>> > > >>> > > >>> > > >>> > > -- >>> > > Carmine Pagliaro >>> > > Research Fellow Neuroimaging Unit >>> > > Institute of Bioimaging and Molecular Physiology-CNR >>> > > Italy >>> > > Life is for sharing. >>> > > >>> > > >>> > > >>> > > >>> > > -- >>> > > Carmine Pagliaro >>> > > Research Fellow Neuroimaging Unit >>> > > Institute of Bioimaging and Molecular Physiology-CNR >>> > > Italy >>> > > Life is for sharing. >>> > > >>> > >>> > >>> > >>> > >>> > -- >>> > Carmine Pagliaro >>> > Research Fellow Neuroimaging Unit >>> > Institute of Bioimaging and Molecular Physiology-CNR >>> > Italy >>> > Life is for sharing. >>> > >>> >>> >> >> >> -- >> Carmine Pagliaro >> Research Fellow Neuroimaging Unit >> Institute of Bioimaging and Molecular Physiology-CNR >> Italy >> *Life is for sharing.* >> >> > -- Carmine Pagliaro Research Fellow Neuroimaging Unit Institute of Bioimaging and Molecular Physiology-CNR Italy *Life is for sharing.*