Push-Nachrichten von MacTechNews.de
Würden Sie gerne aktuelle Nachrichten aus der Apple-Welt direkt über Push-Nachrichten erhalten?
Forum>Software>HILFE: Terminal Script findet Datei nicht obwohl identische Befehlszeile direkt in Terminal funktioniert

HILFE: Terminal Script findet Datei nicht obwohl identische Befehlszeile direkt in Terminal funktioniert

SvenHall25.11.0919:43
Hallo

Ich möchte ein script in Terminal laufen lassen. Es geht um Verarbeitung von MRI Daten mit FSL, das ist aber eigentlich nicht relevant.

Dazu muss ich für jeden Probanden folgenden Befehl eingeben

dtifit -k /Users/sven/MCI-HUG/PAT01-WM_EDDY.nii.gz -o PAT01-WM.nii -m PAT01-WM_mask.nii.gz -r /Users/sven/MCI-HUG/MCI_bvecs.txt -b /Users/sven/MCI-HUG/MCI_bvals.txt
dtifit -k /Users/sven/MCI-HUG/PAT02-WM_EDDY.nii.gz -o PAT02-WM.nii -m PAT02-WM_mask.nii.gz -r /Users/sven/MCI-HUG/MCI_bvecs.txt -b /Users/sven/MCI-HUG/MCI_bvals.txt
dtifit -k /Users/sven/MCI-HUG/PAT02-WM_EDDY.nii.gz -o PAT02-WM.nii -m PAT02-WM_mask.nii.gz -r /Users/sven/MCI-HUG/MCI_bvecs.txt -b /Users/sven/MCI-HUG/MCI_bvals.txt
...

Wenn ich das in Terminal direkt eingebe funktioniert es problemlos.

Ich wollte nun ein Script machen, weil ich vorher und nachher noch weitere Befehle habe. Die funktionieren auch.
Nur diese Zeile funktioniert nicht, obwohl ich wirklich copy - paste mit dem Befehl aus Terminal mache.

Die Fehlermeldung:
Could not open matrix file /Users/sven/MCI-HUG/MCI_bvals.txt

Der Befehl hat 4 Input files. Die beiden .nii.gz Dateien sind MRI Daten, die beiden .txt Dateien sind einfache text files.


Ich verstehe nicht warum die exakt selbe Zeile funktioniert wenn ich sie direkt in Terminal mache, aber nicht funktioniert wenn ich sie in ein script mache.

Kann mir bitte jemand helfen?

Herzlichen Dank
Sven
0

Kommentare

sierkb25.11.0920:10
Auf welche Weise bettest Du diese Zeile denn in Dein Script ein?
Hilfreich wäre da bestimmt, wenn Du das Skript hier mal (wenigstens auszugsweise und gekürzt um die irrelevanten Bestandteile) zur Ansicht posten könntest. Vielleicht ist da ja ein Syntaxfehler im Script drin (z.B. ein Leerzeichen zu wenig oder ein Anführungszeichen zuviel/zuwenig o.ä.).

Frage: Hintergrund des Ganzen ist , ? (via Google gefunden, das obige CLI-Kommando dtifit und die -k/o/m/r/b-Optionen ergeben durch die dortige Doku Sinn)
0
_mäuschen
_mäuschen25.11.0920:14

Note that you must set up the environment variable

0
sierkb25.11.0920:27
_mäuschen
Note that you must set up the environment variable

Du meinst ?

Also:
Note that you must set up the environment variable FSLDIR to point to the directory where FSL is installed on your machine. It is also necessary to source a setup file. This can be done by:

* bash users: . $FSLDIR/etc/fslconf/fsl.sh
* tcsh users: source $FSLDIR/etc/fslconf/fsl.csh

Also, you would normally want to include $FSLDIR/bin in your PATH. In general these are best done in your shell startup file (e.g. .bashrc or .profile). The syntax required depends on the shell you use, but is normally either one of the following (where /usr/local/fsl is used as an example for the installation location):

* bash users: export FSLDIR=/usr/local/fsl; . $FSLDIR/etc/fslconf/fsl.sh ; export PATH=$PATH:$FSLDIR/bin;
* tcsh users: setenv FSLDIR /usr/local/fsl; source $FSLDIR/etc/fslconf/fsl.csh ; setenv PATH ${PATH}:$FSLDIR/bin; rehash;

0
SvenHall30.11.0913:09
Hallo

Danke für Eure Hilfe

Ich muss ich für jeden Probanden folgende 3 Befehle hintereinander machen

eddy_correct PAT01-WM PAT01-WM_EDDY 0
bet PAT01-WM PAT01-WM -m -f 0.2 -n
dtifit -k PAT01-WM_EDDY -o PAT01-WM -m PAT01-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals

Wenn ich einen Befehl nach dem anderen in TERMINAL eingebe ist es kein Problem. Das ist aber viel tippen, ausserdem kann das dann nicht über Nacht laufen.

Ich habe daher ein text-file gemacht, dort für 10 Probanden den text eingegeben
eddy_correct PAT01-WM PAT01-WM_EDDY 0
bet PAT01-WM PAT01-WM -m -f 0.2 -n
dtifit -k PAT01-WM_EDDY -o PAT01-WM -m PAT01-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT02-WM PAT02-WM_EDDY 0
bet PAT02-WM PAT02-WM -m -f 0.2 -n
dtifit -k PAT02-WM_EDDY -o PAT02-WM -m PAT02-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT03-WM PAT03-WM_EDDY 0
bet PAT03-WM PAT03-WM -m -f 0.2 -n
dtifit -k PAT03-WM_EDDY -o PAT03-WM -m PAT03-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT04-WM PAT04-WM_EDDY 0
bet PAT04-WM PAT04-WM -m -f 0.2 -n
dtifit -k PAT04-WM_EDDY -o PAT04-WM -m PAT04-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT05-WM PAT05-WM_EDDY 0
bet PAT05-WM PAT05-WM -m -f 0.2 -n
dtifit -k PAT05-WM_EDDY -o PAT05-WM -m PAT05-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT06-WM PAT06-WM_EDDY 0
bet PAT06-WM PAT06-WM -m -f 0.2 -n
dtifit -k PAT06-WM_EDDY -o PAT06-WM -m PAT06-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT07-WM PAT07-WM_EDDY 0
bet PAT07-WM PAT07-WM -m -f 0.2 -n
dtifit -k PAT07-WM_EDDY -o PAT07-WM -m PAT07-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT08-WM PAT08-WM_EDDY 0
bet PAT08-WM PAT08-WM -m -f 0.2 -n
dtifit -k PAT08-WM_EDDY -o PAT08-WM -m PAT08-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT09-WM PAT09-WM_EDDY 0
bet PAT09-WM PAT09-WM -m -f 0.2 -n
dtifit -k PAT09-WM_EDDY -o PAT09-WM -m PAT09-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals
eddy_correct PAT10-WM PAT10-WM_EDDY 0
bet PAT10-WM PAT10-WM -m -f 0.2 -n
dtifit -k PAT10-WM_EDDY -o PAT10-WM -m PAT10-WM_mask.nii.gz -r MCI_bvecs -b MCI_bvals

dann mit chmod 777 ein ausführbares file gemacht (svens_batch)

wenn ich nun im Verzeichnis mit den files ./svens_batch eingebe, dann startet es prima, die erste Zeile wird auch korrekt ausgeführt, aber bei der 2. Zeile kommt dann folgender Fehler

Could not open matrix file /Users/sven/MCI-HUG/MCI_bvals

Es sind eben nicht nur 10 sondern gut 100 Probanden, so dass sich ein Script schon lohnen würde!

Ich weiss nicht woran es liegt Oder was ich tun kann es zu ändern

Alternativ könnte ich auch ein script machen welche ein filename als Input hat (z.B. PAT-01-WM.nii), und welches dieses als Variable nimmt und dann die 3 Zeilen nacheinander abarbeitet. Ich weiss aber weder wie das geht, noch ob das das Problem umgehen würde

Vielen Dank für die Hilfe

Sven








0
SvenHall30.11.0913:12
P.S.:
noch die commands

eddy_correct
Usage: eddy_correct <4dinput> <4doutput> <reference_no>

bet
Usage: bet <input> <output> [options]

Main bet2 options:
-o generate brain surface outline overlaid onto original image
-m generate binary brain mask
-s generate approximate skull image
-n don't generate segmented brain image output
-f <f> fractional intensity threshold (01); default=0.5; smaller values give larger brain outline estimates
-g <g> vertical gradient in fractional intensity threshold (-11); default=0; positive values give larger brain outline at bottom, smaller at top
-r <r> head radius (mm not voxels); initial surface sphere is set to half of this
-c <x y z> centre-of-gravity (voxels not mm) of initial mesh surface.
-t apply thresholding to segmented brain image and mask
-e generates brain surface as mesh in .vtk format

Variations on default bet2 functionality (mutually exclusive options):
(default) just run bet2
-R robust brain centre estimation (iterates BET several times)
-S eye & optic nerve cleanup (can be useful in SIENA)
-B bias field & neck cleanup (can be useful in SIENA)
-Z improve BET if FOV is very small in Z (by temporarily padding end slices)
-F apply to 4D FMRI data (uses -f 0.4 and dilates brain mask slightly)
-A run bet2 and then betsurf to get additional skull and scalp surfaces (includes registrations)
-A2 <T2> as with -A, when also feeding in non-brain-extracted T2 (includes registrations)

Miscellaneous options:
-v verbose (switch on diagnostic messages)
-h display this help, then exits
-d debug (don't delete temporary intermediate images)

dtifit

Usage:
dtifit -k <filename>
dtifit --verbose


Compulsory arguments (You MUST set one or more of):
-k,--data dti data file
-o,--out Output basename
-m,--mask Bet binary mask file
-r,--bvecs b vectors file
-b,--bvals b values file

Optional arguments (You may optionally specify one or more of):
-V,--verbose switch on diagnostic messages
-h,--help display this message
--cni Input counfound regressors
--sse Output sum of squared errors
--littlebit Only process small area of brain
--save_tensor Save the elements of the tensor
-z,--zmin min z
-Z,--zmax max z
-y,--ymin min y
-Y,--ymax max y
-x,--xmin min x
-X,--xmax max x

0

Kommentieren

Diese Diskussion ist bereits mehr als 3 Monate alt und kann daher nicht mehr kommentiert werden.