Dear R,
Yes, I have tried to run "samseg_run" from the command line (I've repeated my syntax below).? I have looked both under the directory where the command ran that produced the ?Illegal instruction? error.? No crash file (a logfile?) or a "core" file were written.?
I also looked?/var/crash but that folder was empty too.
As I mentioned, I'm a LINUX novice.? I'm even more of a novice with regard to Python. However, I did take a quick at the code looking for any mention of tensorflow, and have copied the python script text as it exists below.? I have highlighted the only mention
of tensorflow below.? Does this look like you expect it?
Has tensorflow actually been incorporated into the VM???
Note that I have been able to successfully run Samseg without the --lesion flag and the process works just fine (about 20min runtime, aseg looks just fine in Freeview)
Again, thanks for any guidance you can provide.
-Randy
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#!/usr/bin/env python
import osimport sysimport jsonimport scipy.ioimport freesurfer as fsimport freesurfer.samseg as samseg
# ------ Parse Command Line Arguments ------
parser = fs.utils.ArgumentParser()
default_threads = int(os.environ.get('OMP_NUM_THREADS', 1))
# requiredparser.add_argument('-o', '--output', metavar='DIR', dest='outputDirectory', help='Output directory.', required=True)parser.add_argument('-i', '--input', nargs='+', action='extend', metavar='FILE', dest='inputFileNames', help='Input image(s).', required=True)#
optional processing optionsparser.add_argument('-m', '--mode', nargs='+', help='Output basenames for the input image mode.')parser.add_argument('--threads', type=int, default=default_threads, help='Number of threads to use. Defaults to current OMP_NUM_THREADS
or 1.')parser.add_argument('--reg-only', action='store_true', default=False, help='Only perform initial affine registration.')parser.add_argument('-r', '--reg', metavar='FILE', help='Skip initial affine registration and read transform from file.')parser.add_argument('--init-reg',
metavar='FILE', help='Initial affine registration.')parser.add_argument('-a', '--atlas', metavar='DIR', help='Point to an alternative atlas directory.')parser.add_argument('--gmm', metav
ar='FILE', help='Point to an alternative GMM file.')parser.add_argument('--ignore-unknown', action='store_true', help='Ignore final priors corresponding to unknown class.')parser.add_argument('--options', metavar='FILE', help='Override advanced options via
a json file.')parser.add_argument('--pallidum-separate', action='store_true', default=False, help='Move pallidum outside of global white matter class. Use this flag when T2/flair is used.')# optional lesion optionsparser.add_argument('--lesion', action='store_true',
default=False, help='Enable lesion segmentation (requires tensorflow).')parser.add_argument('--threshold', type=float, default=0.3, help='Lesion threshold for final segmentation. Lesion segmentation must be enabled.')parser.add_argument('--samples', type=int,
default=50, help='Number of samples for lesion segmentation. Lesion segmentation must be enabled.')parser.add_argument('--burnin', type=int, default=50, help='Number of burn-in samples for lesion segmentation. Les
ion segmentation must be enabled.')parser.ad!
d_argume
nt('--lesion-pseudo-samples', nargs=2, type=float, default=[500, 500], help='Lesion pseudo samples mean and variance.')parser.add_argument('--lesion-rho', type=float, default=50, help='Lesion ratio.')parser.add_argument('--lesion-mask-structure', default='Cortex',
help='Intensity mask brain structure. Lesion segmentation must be enabled.')parser.add_argument('--lesion-mask-pattern', type=int, nargs='+', help='Lesion mask list (set value for each input volume): -1 below lesion mask structure mean, +1 above, 0 no mask.
Lesion segmentation must be enabled.')# optional debugging optionsparser.add_argument('--history', action='store_true', default=False, help='Save history.')parser.add_argument('--save-posteriors', nargs='*', help='Save posterior volumes to the "posteriors"
subdirectory.')parser.add_argument('--save-probabilities', action='store_true', help='Save final modal class probabilities to "probabilities" subdirectory.')parser.add_argument('--showfigs', action='store_true', defaul
t=False, help='Show figures during run.')parser.add_argument('--save-mesh', action='store_true', help='Save the final mesh in template space.')parser.add_argument('--save-warp', action='store_true', help='Save the image->template warp field.')parser.add_argument('--movie',
action='store_true', default=False, help='Show history as arrow key controlled time sequence.')
args = parser.parse_args()
# ------ Initial Setup ------
# Make sure freesurfer has been sourcedif not fs.fshome():? ? fs.fatal('FREESURFER_HOME must be set')
# Start the process timertimer = fs.utils.Timer()
# Create the output folderos.makedirs(args.outputDirectory, exist_ok=True)
# Specify the maximum number of threads the GEMS code will usesamseg.setGlobalDefaultNumberOfThreads(args.threads)
# Remove previous cost logcostfile = os.path.join(args.outputDirectory, 'cost.txt')if os.path.exists( costfile ):? ? os.remove( costfile )?
# Get the atlas directoryatlasDir = os.environ.get('SAMSEG_DATA_DIR')if args.atlas:? ? atlasDir = args.atlasif not atlasDir:? ? # Altas defaults? ? if args.lesion:? ? ? ? defaultAtlas = '20Subjects_smoothing2_down2_smoothingForAffine2_lesion'? ? else:? ? ?
? defaultAtlas = '20Subjects_smoothing2_down2_smoothingForAffine2'? ? atlasDir = os.path.join(fs.fshome(), 'average', 'samseg', defaultAtlas)
# Setup the visualization toolvisualizer = samseg.initVisualizer(args.showfigs, args.movie)
# ------ Prepare Samseg Parameters ------
# Load user options from a JSON fileuserModelSpecifications = {}userOptimizationOptions = {}if args.options:? ? with open(args.options) as f:? ? ? ? userOptions = json.load(f)? ? if userOptions.get('modelSpecifications') is not None:?? ? ? ? userModelSpecifications
= userOptions.get('modelSpecifications')? ? if userOptions.get('optimizationOptions') is not None:?? ? ? ? userOptimizationOptions = userOptions.get('optimizationOptions')
# Check if --save-posteriors was specified without any structure search stringif args.save_posteriors is not None and len(args.save_posteriors) == 0:? ? savePosteriors = Trueelse:? ? savePosteriors = args.save_posteriors
# ------ Run Samseg ------
samseg_kwargs = dict(? ? imageFileNames=args.inputFileNames,? ? atlasDir=atlasDir,? ? savePath=args.outputDirectory,? ? userModelSpecifications=userModelSpecifications,? ? userOptimizationOptions=userOptimizationOptions,? ? targetIntensity=110,? ? targetSearchStrings=[
'Cerebral-White-Matter' ],? ? visualizer=visualizer,? ? saveHistory=args.history,? ? saveMesh=args.save_mesh,? ? savePosteriors=savePosteriors,? ? saveWarp=args.save_warp,? ? modeNames=args.mode,? ? pallidumAsWM=(not args.pallidum_separate),? ? saveModelProbabilities=args.save_probabilities,?
? gmmFileName=args.gmm,? ? ignoreUnknownPriors=args.ignore_unknown,)
if args.lesion:
? ? # If lesion mask pattern is not specified, assume inputs are T1-contrast? ? lesion_mask_pattern = args.lesion_mask_pattern? ? if lesion_mask_pattern is None:? ? ? ? lesion_mask_pattern = [0] * len(args.inputFileNames)? ? ? ? print('Defaulting lesion mask
pattern to %s' % str(lesion_mask_pattern))
? ? # Delay import until here so that tensorflow doesn't get loaded unless needed? ? from freesurfer.samseg.SamsegLesion import SamsegLesion? ? samseg = SamsegLesion(**samseg_kwargs,? ? ? ? numberOfPseudoSamplesMean=args.lesion_pseudo_samples[0],? ? ? ? numberOfPseudoSamplesVariance=args.lesion_pseudo_samples[1],?
? ? ? rho=args.lesion_rho,? ? ? ? intensityMaskingSearchString=args.lesion_mask_structure,? ? ? ? intensityMaskingPattern=lesion_mask_pattern,? ? ? ? numberOfBurnInSteps=args.burnin,? ? ? ? numberOfSamplingSteps=args.samples,? ? ? ? threshold=args.threshold?
? )
else:? ? samseg = samseg.Samseg(**samseg_kwargs)
_, _, _, optimizationSummary = samseg.segment(? ? costfile=costfile,? ? timer=timer,? ? transformFile=args.reg,? ? initTransformFile=args.init_reg,? ? reg_only=args.reg_only)
# Save a summary of the optimization processwith open(costfile, 'a') as file:? ? for multiResolutionLevel, item in enumerate(optimizationSummary):? ? ? ? file.write('atlasRegistrationLevel%d %d %f\n' % (multiResolutionLevel, item['numberOfIterations'], item['perVoxelCost']))
timer.mark('run_samseg complete')
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PS. Repeating the syntax from below.
run_samseg --input /home/developer/subjects_new/o_ADNI_002_S_4654__MRI-m072__LMCI-LMCI__20180522__T30-acc_orig__S689126_I1001975.nii /home/developer/subjects_new/rT1_o_ADNI_002_S_4654__MRI-m072__LMCI-LMCI__20180522__T2-FLAIR__S689135_I1001984.nii --pallidum-separate
--lesion --lesion-mask-pattern 0 1 --output /home/developer/subjects_new/Lesion-test/
-----Original Message-----
From: fsbuild <fsbuild@contbay.com>
To: freesurfer@nmr.mgh.harvard.edu
Cc: daedalus39@aol.com
Sent: Thu, Feb 24, 2022 5:15 pm
Subject: Re: [Freesurfer] SAMSEG "lesion" (Illegal instruction) ~ running VM_67
Hello Randy,
I think the expectation is for users to run ?samseg? from the command line. ?(The samseg script is a front-end you run with command line options, e.g., ?help, which calls samseg_run that in turn runs the samseg python scripts in the freesurfer python distribution
which includes the tensorflow code).
I can?t speak to the validity of the command + options causing the crash, but I would look too see if a ?core? file was written in the directory where the command ran that produced the ?Illegal instruction? error and subsequent crash. ?The core file might also
be under /var/crash. ?If you have the core file you could name it something unique and try uploading it to?https://secure-web.cisco.com/1_8ugcIT497YTUyY1vRRMjZbWfONaiAbR1P1Zg9-6zNbgUF_nqdNpH5IkjDRGIBnRgkeymgi17VUaKZZtvSteYJHtbAzdHwJ-ZFuNUEKFvUYllMIfuKFt_TYxmPnYvE0kZsxksjMWlCFeZ0BtBLLYdcPSgze4QZ_08HI5pmGrhOks3kznF06Y51NQkC-1is6UmZRsyIu9BdtoZrqWH6yB_tj0xHbOP9ZP2mxnhHC42-V0CdDffxKxsXQvIJ7N8gf75oN1anvwYhugReEzKkv2FVmdURFYOfKkwk5q4Ivr9iS2lKqdZe_QwPgWrnBUmbz8K3-CmecHut4ttLt-fwkNhQ/https%3A%2F%2Fgate.nmr.mgh.harvard.edu%2Ffiledrop2%2F?for
someone to look at.
- R.
On Feb 24, 2022, at 11:58, daedalus39@aol.com wrote:
????????External Email - Use Caution????????
Following up on yesterday's email:
I looked up the help text for SAMSEG on the VM (?run_samseg ?help?).??The flag for --lesion indicates that Tensorflow is required.???? --lesion??????? Enable lesion segmentation (requires tensorflow).?I'm not sure is tensorflow is installed in VM_67, but "which
tensorflow" returned nothing.? While my question only reported the ?core dump? and a request to check the syntax, I did ask if the ?lesion? flag was implemented in the VM.??
If it's not installed in VM_67, would you be able to offer some guidance as to where the safest download site is and some suggestions as to how to install it?
Sincerely,
-Randy
-----Original Message-----
From: daedalus39@aol.com
To: freesurfer@nmr.mgh.harvard.edu <freesurfer@nmr.mgh.harvard.edu>
Sent: Wed, Feb 23, 2022 1:19 pm
Subject: SAMSEG "lesion" (Illegal instruction) ~ running VM_67
Dear Experts,
I am trying to test SAMSEG "lesion" on VM_67 and after I entered:
run_samseg --input /home/developer/subjects_new/o_ADNI_002_S_4654__MRI-m072__LMCI-LMCI__20180522__T30-acc_orig__S689126_I1001975.nii /home/developer/subjects_new/rT1_o_ADNI_002_S_4654__MRI-m072__LMCI-LMCI__20180522__T2-FLAIR__S689135_I1001984.nii --pallidum-separate
--lesion --lesion-mask-pattern 0 1 --output /home/developer/subjects_new/Lesion-test/
...I got the following error
Illegal instruction (core dumped)
Is there anything glaringly wrong in my instruction/input phrase?
Is SAMSEG "lesion" implemented in the new VM?? I was able to test the "basic" SAMSEG with a single T1 earlier this morning (it ran just fine)
Thanks in advance for any help.
-Randy_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://secure-web.cisco.com/1ajCHs20Ntg5vd9AD9I6GP72nyffMyNANWVvUGOngP_c0acAh69UqWUgMHsVdUJPPw6V-jdxSE8Bv3pMtpmpbmhckwOsjRl7kK7QTTXDWbDuug2iazQJmjobCOo4cDPKvES_4Y8bT_ZwpgRK3EbHwj9EUIrbcYkWgRsbyyEU946VLAqQy0xNaYqAsQ1gDrfHI8-keBDroWyejutKjeoZeeiPn9uVRuSPsO_o5FpyWBzxLwObGkKIL_iPx8gH4S9eY7_gxOZvEunVbngAs4wwLjv6RJQ4zqPEtV40rEciaRZdew3pFmA50yhfxWto37C-yWzjjscKvT_B_WLc7oHErXA/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Ffreesurfer
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://mail.nmr.mgh.harvard.edu/pipermail/freesurfer/attachments/20220226/7826a479/attachment-0001.html
------------------------------
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
End of Freesurfer Digest, Vol 216, Issue 39
*******************************************