mne_organize_dicom not found when making flash bem

  • MNE version: MNE1.0.0
  • operating system: windows10

Hi all,
Iā€™m trying to do the coregistration after the step of recon-all and make_scalp_surfaces(). Here are my code snippets of these two steps:

# recon-all
export SUBJECTS_DIR=/seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/
my_subject=subj-41
my_NIfTI=/brain/guixue/zhouyu/proj01/mri/nifti/sub-41/anat/sub-41_T1w.nii.gz
recon-all -i $my_NIfTI -s $my_subject -all
# make_scalp_surfaces
subject = 'subj-41'
subjects_dir = '/brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/'
mne.bem.make_scalp_surfaces(subject, subjects_dir=subjects_dir, force=True, overwrite=False, no_decimate=False, verbose=None)

and the result folder of reconstruction for this subject looked like this:
image

then I print ā€˜mne coregā€™ in the terminal to initiate the coregistration GUI, and here is the error message I got:

Using pyvistaqt 3d backend.

Using high resolution head model in E:\proj01\analysis\fmri\freesurfer\recon_all\subj-41\bem\subj-41-head-dense.fif
Traceback (most recent call last):
  File "D:\anaconda3\envs\mne\Scripts\mne-script.py", line 9, in <module>
    sys.exit(main())
  File "D:\anaconda3\envs\mne\lib\site-packages\mne\commands\utils.py", line 107, in main
    cmd.run()
  File "D:\anaconda3\envs\mne\lib\site-packages\mne\commands\mne_coreg.py", line 85, in run
    mne.gui.coregistration(
  File "<decorator-gen-558>", line 12, in coregistration
  File "D:\anaconda3\envs\mne\lib\site-packages\mne\gui\__init__.py", line 193, in coregistration
    return CoregistrationUI(
  File "<decorator-gen-570>", line 12, in __init__
  File "D:\anaconda3\envs\mne\lib\site-packages\mne\gui\_coreg.py", line 238, in __init__
    self.coreg = Coregistration(
  File "D:\anaconda3\envs\mne\lib\site-packages\mne\coreg.py", line 1371, in __init__
    self._setup_bem()
  File "D:\anaconda3\envs\mne\lib\site-packages\mne\coreg.py", line 1426, in _setup_bem
    'mesh (%d vertices): %s' % (len(self._bem_high_res.surf.rr),
AttributeError: 'dict' object has no attribute 'surf'

then I thought maybe because I didnā€™t do the make_flash_bem step, this error message occurred.
so I start constructing the BEM surface. I had flash images for some of my subjects, here are the flash images files of one subject:

I followed the instruction in this page https://mne.tools/dev/generated/mne.bem.convert_flash_mris.html, which in Notes section says that

Before running this script do the following: (unless convert=False is specified)

  1. Copy all of your FLASH images in a single directory and

create a directory to hold the output of mne_organize_dicom

  1. cd to and run

$ mne_organize_dicom to create an appropriate directory structure

  1. Create symbolic links to make flash05 and flash30 point to the

appropriate series: ln -s <FLASH 5 series dir> flash05 ln -s <FLASH 30 series dir> flash30 Some partition formats (e.g. FAT32) do not support symbolic links. In this case, copy the file to the appropriate series: cp <FLASH 5 series dir> flash05 cp <FLASH 30 series dir> flash30

  1. cd to the directory where flash05 and flash30 links are
  2. Set SUBJECTS_DIR and SUBJECT environment variables appropriately
  3. Run this script

The fact is I stuck in the step 2,
mne_organize_dicom /brain/guixue/zhouyu/proj01/mri/nifti/sub-41/flash_source, the error I got is:
bash: mne_organize_dicom: command not found

Iā€™m really confused about what should I do to solve this problem, any suggestions? Thanks a lot! :heart: :heart: :heart:

Best

did you modify manually some files in the recon-all output subject folder?

Alex

Hi! Alex,
Thank you for your reply :grin:
I didnā€™t manually modify any files in the recon-all output subject folder. Taking sub-41 as an example, after the recon-all, the output subject folder structure looked like this except the ā€˜bemā€™ folder which didnā€™t exist until the make_scalp_surfaces() step.

and my nifti folder looked like this:


in this case, the flash dicoms were already converted to .nii.gz format.
1)Should I convert the flash DICOM to .mgz format?
2) I followed the instructions of the Notes section mne.bem.convert_flash_mris ā€” MNE 1.1.dev0 documentation despite the step 2 didnā€™t work, I create the flash05 and flash30 symbolic links in the folder: ā€˜flash_destā€™

and then run mne flash_bem --subject=sub-41 dir=/brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all --view,
the error prompted that

---- Converting Flash images ----
Traceback (most recent call last):
  File "/brain/guixue/.conda/envs/mne/bin/mne", line 8, in <module>
    sys.exit(main())
  File "/brain/guixue/.conda/envs/mne/lib/python3.8/site-packages/mne/commands/utils.py", line 107, in main
    cmd.run()
  File "/brain/guixue/.conda/envs/mne/lib/python3.8/site-packages/mne/commands/mne_flash_bem.py", line 100, in run
    convert_flash_mris(subject=subject, subjects_dir=subjects_dir,
  File "<decorator-gen-69>", line 22, in convert_flash_mris
  File "/brain/guixue/.conda/envs/mne/lib/python3.8/site-packages/mne/bem.py", line 1759, in convert_flash_mris
    raise RuntimeError("Directory %s is missing."
RuntimeError: Directory flash05/002 is missing.

I assumed this error resulted from the failure in step 2 where the
mne_organize_dicom: command not found, so the folder structure was wrong.
Itā€™s kind of a mess in my mind now, what should I do :dizzy_face: :face_with_spiral_eyes: :exploding_head:

if you have .nii files you donā€™t need the mne_organize_dicom command

I am a bit lost here

Alex

1 Like

+1 on this. You should only need to run recon-all, and this should produce everything you need to get to work with MNE-Pythonā€¦ (well, except for the BEM and head surface, but you already know how to create those)

1 Like

My biggest confusion is about how to create the flash bem. In my subject folders of recon-all output, there seem no flash image files in $SUBJECTS_DIR/$SUBJECT/mri/flash/parameter_maps, which means that the recon-all didnā€™t process the flash .nii.gz files in my nifiti folder. Or are the flash .nii.gz files in my nifiti folder is all the mne flash_bem needs?

Thatā€™s the problem then. Iā€™m not sure how you ended up this way, but the directory must not be empty if you want to use FLASH imagesā€¦

1 Like

Here is the original DICOM folder structure of one subject (sub-41) in which there were 4 folders of flash images:
image

and this is the folder structure of nfiti files converted from DICOMs:

since recon-all didnā€™t process the flash images, would it be there is something wrong with these flash images?

what you looked the doc of https://mne.tools/stable/generated/mne.bem.make_flash_bem.html

flash_path parameter may help?

recon-all does not do anything with the flash images

ALex

2 Likes

Hi! Alex,
I tried your suggestion, glad we move forward a little bit because another error occurred, here is my code:

subject = 'sub-41'

subjects_dir = '/seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/'

flash_path = '/seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/'

mne.bem.make_flash_bem(subject, overwrite=False, show=True, subjects_dir=subjects_dir, flash_path=flash_path, copy=False, verbose=None)

here is the error message (sorry itā€™s long :face_holding_back_tears:):

Processing the flash MRI data to produce BEM meshes with the following parameters:
SUBJECTS_DIR = /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all
SUBJECT = sub-41
Result dir = /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/bem/flash


---- Registering flash 5 with MPRAGE ----
Running subprocess: fsl_rigid_register -r /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/mri/T1.mgz -i /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz -o /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5_reg.mgz






$Id: fsl_rigid_register,v 1.33 2016/02/16 17:17:20 zkaufman Exp $

Mon 28 Mar 2022 09:49:00 PM CST

/seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5_reg.mgz

--------------------------------------

/tmp/tmp_mne_tempdir_bldfvslo

mri_convert /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/mri/T1.mgz /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/refvol.fsl_rigid_register.nii

mri_convert.bin /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/mri/T1.mgz /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/refvol.fsl_rigid_register.nii 

$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $

reading from /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/mri/T1.mgz...

TR=2530.00, TE=0.00, TI=0.00, flip angle=0.00

i_ras = (-1, 9.84528e-11, 0)

j_ras = (0, 0, -1)

k_ras = (1.34378e-10, 1, 3.63798e-12)

writing to /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/refvol.fsl_rigid_register.nii...

--------------------------------------

/tmp/tmp_mne_tempdir_bldfvslo

mri_convert /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/invol.fsl_rigid_register.nii

mri_convert.bin /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/invol.fsl_rigid_register.nii 

$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $

reading from /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz...

mghRead(/seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz, -1): could not open file

('\n\n\n$Id: fsl_rigid_register,v 1.33 2016/02/16 17:17:20 zkaufman Exp $\nMon 28 Mar 2022 09:49:00 PM CST\n/seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5_reg.mgz\n--------------------------------------\n/tmp/tmp_mne_tempdir_bldfvslo\nmri_convert /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/mri/T1.mgz /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/refvol.fsl_rigid_register.nii\nmri_convert.bin /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/mri/T1.mgz /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/refvol.fsl_rigid_register.nii \n$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $\nreading from /seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/mri/T1.mgz...\nTR=2530.00, TE=0.00, TI=0.00, flip angle=0.00\ni_ras = (-1, 9.84528e-11, 0)\nj_ras = (0, 0, -1)\nk_ras = (1.34378e-10, 1, 3.63798e-12)\nwriting to /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/refvol.fsl_rigid_register.nii...\n--------------------------------------\n/tmp/tmp_mne_tempdir_bldfvslo\nmri_convert /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/invol.fsl_rigid_register.nii\nmri_convert.bin /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/fsl_rigid_register.22494/invol.fsl_rigid_register.nii \n$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $\nreading from /seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz...\n', 'mghRead(/seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz, -1): could not open file\n')
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 mne.bem.make_flash_bem(subject, overwrite=False, show=True, subjects_dir=subjects_dir, flash_path=flash_path, copy=False, verbose=None)

File <decorator-gen-76>:12, in make_flash_bem(subject, overwrite, show, subjects_dir, flash_path, copy, verbose)

File ~/anaconda2/envs/mne/lib/python3.10/site-packages/mne/bem.py:1906, in make_flash_bem(subject, overwrite, show, subjects_dir, flash_path, copy, verbose)
   1903         ref_volume = op.join(mri_dir, 'T1')
   1904     cmd = ['fsl_rigid_register', '-r', ref_volume, '-i', flash5,
   1905            '-o', flash5_reg]
-> 1906     run_subprocess_env(cmd)
   1907 else:
   1908     logger.info("Registered flash 5 image is already there")

File <decorator-gen-1>:12, in run_subprocess(command, return_code, verbose, *args, **kwargs)

File ~/anaconda2/envs/mne/lib/python3.10/site-packages/mne/utils/misc.py:170, in run_subprocess(command, return_code, verbose, *args, **kwargs)
    168 err_fun = subprocess.CalledProcessError.__init__
    169 if 'output' in _get_args(err_fun):
--> 170     raise subprocess.CalledProcessError(p.returncode, command, output)
    171 else:
    172     raise subprocess.CalledProcessError(p.returncode, command)

CalledProcessError: Command '['fsl_rigid_register', '-r', '/seastor/zhouyu0206/proj01/fmri/freesurfer/recon_all/sub-41/mri/T1.mgz', '-i', '/seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz', '-o', '/seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5_reg.mgz']' returned non-zero exit status 1.

my flash images folder looks like this:

my subject recon-all output folder looks like this:
image

the error says:

/seastor/zhouyu0206/proj01/fmri/nifti/sub-41/flash/flash5.mgz

is not found.

So the flash5 file should be called like this. I think the API
is really rough on the edges but I least it should help

Alex

1 Like

Hi! Alex and Richard,
I think I kind of found a solution to process my flash images. The reason for the recon-all didnā€™t process my flash images might be they are multi-echo Flash sequence (MEF) data while FreeSurfer is not optimized for the processing of MEF data yet, but it did give two solutions here MEF - Free Surfer Wiki
and I used the second one from step1-3. and then use the mne.bem.make_flash_bem(subject, overwrite=False, show=True, subjects_dir=subjects_dir, flash_path=None, copy=False, verbose=None), it created the inner skull, outer skull and outer skin surface file, but something went wrong when plot the bem, here is output folder structure and the verbose:

Processing the flash MRI data to produce BEM meshes with the following parameters:
SUBJECTS_DIR = /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all
SUBJECT = sub-41-1
Result dir = /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/flash


---- Registering flash 5 with MPRAGE ----
Registered flash 5 image is already there

---- Converting flash5 volume into COR format ----
Running subprocess: mri_convert /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/flash/parameter_maps/flash5_reg.mgz /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/flash5
mri_convert.bin /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/flash/parameter_maps/flash5_reg.mgz /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/flash5 

$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $

reading from /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/flash/parameter_maps/flash5_reg.mgz...

TR=2530.00, TE=0.00, TI=0.00, flip angle=0.00

i_ras = (-1, 9.84528e-11, 0)

j_ras = (0, 0, -1)

k_ras = (1.34378e-10, 1, 3.63798e-12)

changing data type from float to uchar (noscale = 0)...

MRIchangeType: Building histogram 

writing to /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/flash5...


---- Converting T1 volume into COR format ----
Running subprocess: mri_convert /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/T1.mgz /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/T1
mri_convert.bin /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/T1.mgz /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/T1 

$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $

reading from /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/T1.mgz...

TR=2530.00, TE=0.00, TI=0.00, flip angle=0.00

i_ras = (-1, 9.84528e-11, 0)

j_ras = (0, 0, -1)

k_ras = (1.34378e-10, 1, 3.63798e-12)

writing to /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/T1...


---- Converting brain volume into COR format ----
Running subprocess: mri_convert /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/brain.mgz /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/brain
mri_convert.bin /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/brain.mgz /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/brain 

$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $

reading from /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/brain.mgz...

TR=2530.00, TE=0.00, TI=0.00, flip angle=0.00

i_ras = (-1, 9.84528e-11, 0)

j_ras = (0, 0, -1)

k_ras = (1.34378e-10, 1, 3.63798e-12)

writing to /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/brain...


---- Creating the BEM surfaces ----
Running subprocess: mri_make_bem_surfaces sub-41-1
nvertices=2562, nfaces=5120

mri_strip_skull: triangle file /opt/software/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0/freesurfer/lib/bem/ic4.tri read

mri_strip_skull: images /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/brain/COR- read

xlo=-71.000000, xhi=70.000000, ylo=-84.000000, yhi=76.000000, zlo=-34.000000, zhi=103.000000

0: sval=84.06,sinval=84.06,soutval=84.06

10: sval=69.20,sinval=69.20,soutval=69.20

20: sval=30.72,sinval=30.72,soutval=30.72

30: sval=14.96,sinval=14.96,soutval=14.96

40: sval=13.41,sinval=13.41,soutval=13.41

50: sval=13.98,sinval=13.98,soutval=13.98

60: sval=14.17,sinval=14.17,soutval=14.17

70: sval=13.52,sinval=13.52,soutval=13.52

80: sval=13.51,sinval=13.51,soutval=13.51

90: sval=13.45,sinval=13.45,soutval=13.45

0: ad=0.520972, dmax=1.000000, nclip=0

1: ad=0.478029, dmax=1.000000, nclip=0

2: ad=0.488134, dmax=1.000000, nclip=0

3: ad=0.501572, dmax=1.000000, nclip=0

4: ad=0.490254, dmax=1.000000, nclip=0

5: ad=0.473747, dmax=1.000000, nclip=0

6: ad=0.483116, dmax=1.000000, nclip=0

7: ad=0.491565, dmax=1.000000, nclip=0

8: ad=0.488759, dmax=1.000000, nclip=0

9: ad=0.480460, dmax=1.000000, nclip=0

10: ad=0.497451, dmax=1.000000, nclip=0

11: ad=0.512828, dmax=1.000000, nclip=0

12: ad=0.508317, dmax=1.000000, nclip=0

13: ad=0.502193, dmax=1.000000, nclip=0

14: ad=0.526212, dmax=1.000000, nclip=0

15: ad=0.540898, dmax=1.000000, nclip=0

16: ad=0.524475, dmax=1.000000, nclip=0

17: ad=0.531350, dmax=1.000000, nclip=0

18: ad=0.563880, dmax=1.000000, nclip=0

19: ad=0.560443, dmax=1.000000, nclip=0

20: ad=0.543994, dmax=1.000000, nclip=0

21: ad=0.564087, dmax=1.000000, nclip=0

22: ad=0.594574, dmax=1.000000, nclip=0

23: ad=0.576289, dmax=1.000000, nclip=0

24: ad=0.564603, dmax=1.000000, nclip=0

25: ad=0.596765, dmax=1.000000, nclip=0

26: ad=0.614337, dmax=1.000000, nclip=0

27: ad=0.588984, dmax=1.000000, nclip=0

28: ad=0.588496, dmax=1.000000, nclip=0

29: ad=0.619174, dmax=1.000000, nclip=0

30: ad=0.627111, dmax=1.000000, nclip=0

31: ad=0.597021, dmax=1.000000, nclip=0

32: ad=0.610698, dmax=1.000000, nclip=0

33: ad=0.634660, dmax=1.000000, nclip=0

34: ad=0.632556, dmax=1.000000, nclip=0

35: ad=0.611053, dmax=1.000000, nclip=0

36: ad=0.631502, dmax=1.000000, nclip=0

37: ad=0.644499, dmax=1.000000, nclip=0

38: ad=0.634269, dmax=1.000000, nclip=0

39: ad=0.626527, dmax=1.000000, nclip=0

40: ad=0.644340, dmax=1.000000, nclip=0

41: ad=0.648393, dmax=1.000000, nclip=0

42: ad=0.634235, dmax=1.000000, nclip=0

43: ad=0.640851, dmax=1.000000, nclip=0

44: ad=0.653961, dmax=1.000000, nclip=0

45: ad=0.650836, dmax=1.000000, nclip=0

46: ad=0.636601, dmax=1.000000, nclip=0

47: ad=0.652522, dmax=1.000000, nclip=0

48: ad=0.660308, dmax=1.000000, nclip=0

49: ad=0.651074, dmax=1.000000, nclip=0

0: sval=29.99,sinval=29.99,soutval=29.99

10: sval=14.10,sinval=14.10,soutval=14.10

20: sval=13.84,sinval=13.84,soutval=13.84

30: sval=13.31,sinval=13.31,soutval=13.31

40: sval=13.14,sinval=13.14,soutval=13.14

50: sval=13.90,sinval=13.90,soutval=13.90

60: sval=13.67,sinval=13.67,soutval=13.67

70: sval=13.92,sinval=13.92,soutval=13.92

80: sval=13.24,sinval=13.24,soutval=13.24

90: sval=13.85,sinval=13.85,soutval=13.85

0: ad=0.407971, dmax=1.000000, nclip=0

1: ad=0.228519, dmax=1.000000, nclip=0

2: ad=0.100772, dmax=0.958336, nclip=0

3: ad=0.077238, dmax=0.762616, nclip=0

4: ad=0.054178, dmax=0.687747, nclip=0

5: ad=0.046000, dmax=0.597683, nclip=0

6: ad=0.039925, dmax=0.528905, nclip=0

7: ad=0.035881, dmax=0.477430, nclip=0

8: ad=0.032955, dmax=0.434377, nclip=0

9: ad=0.030635, dmax=0.396509, nclip=0

mri_strip_skull: triangle file /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/inner_skull_tmp.tri written

nvertices=2562, nfaces=5120

mri_strip_skull: triangle file /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/inner_skull_tmp.tri read

mri_strip_skull: images /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/flash5/COR- read

0: sval=73.94,sinval=73.94,soutval=73.94

10: sval= 0.00,sinval= 0.00,soutval= 0.00

20: sval= 0.00,sinval= 0.00,soutval= 0.00

30: sval= 0.00,sinval= 0.00,soutval= 0.00

mri_strip_skull: triangle file /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/inner_skull.tri written

mri_strip_skull: triangle file /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/outer_skull.tri written

nvertices=2562, nfaces=5120

mri_strip_skull: triangle file /opt/software/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0/freesurfer/lib/bem/ic4.tri read

mri_strip_skull: images /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/mri/T1/COR- read

xlo=-82.000000, xhi=79.000000, ylo=-94.000000, yhi=102.000000, zlo=-102.000000, zhi=103.000000

0: sval= 4.89,sinval= 4.89,soutval= 4.89

10: sval= 5.85,sinval= 5.85,soutval= 5.85

20: sval= 7.32,sinval= 7.32,soutval= 7.32

30: sval=10.84,sinval=10.84,soutval=10.84

40: sval=28.12,sinval=28.12,soutval=28.12

50: sval=45.18,sinval=45.18,soutval=45.18

60: sval=58.08,sinval=58.08,soutval=58.08

70: sval=65.99,sinval=65.99,soutval=65.99

80: sval=70.12,sinval=70.12,soutval=70.12

90: sval=71.47,sinval=71.47,soutval=71.47

100: sval=70.91,sinval=70.91,soutval=70.91

110: sval=71.80,sinval=71.80,soutval=71.80

120: sval=71.57,sinval=71.57,soutval=71.57

130: sval=71.73,sinval=71.73,soutval=71.73

140: sval=71.31,sinval=71.31,soutval=71.31

150: sval=71.03,sinval=71.03,soutval=71.03

160: sval=70.77,sinval=70.77,soutval=70.77

170: sval=70.74,sinval=70.74,soutval=70.74

180: sval=70.79,sinval=70.79,soutval=70.79

190: sval=70.80,sinval=70.80,soutval=70.80

0: sval=71.49,sinval=71.49,soutval=71.49

10: sval=66.57,sinval=66.57,soutval=66.57

20: sval=66.01,sinval=66.01,soutval=66.01

30: sval=65.63,sinval=65.63,soutval=65.63

40: sval=66.25,sinval=66.25,soutval=66.25

50: sval=66.34,sinval=66.34,soutval=66.34

60: sval=65.21,sinval=65.21,soutval=65.21

70: sval=65.40,sinval=65.40,soutval=65.40

80: sval=65.13,sinval=65.13,soutval=65.13

90: sval=65.33,sinval=65.33,soutval=65.33

mri_strip_skull: triangle file /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/outer_skin.tri written


---- Converting the tri files into surf files ----
Loaded surface from /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/flash/inner_skull.tri with 2562 nodes and 5120 triangles.
Node normals were not included in the source file.
Loaded surface from /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/flash/outer_skull.tri with 2562 nodes and 5120 triangles.
Node normals were not included in the source file.
Loaded surface from /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/flash/outer_skin.tri with 2562 nodes and 5120 triangles.
Node normals were not included in the source file.

---- Cleaning up ----
Deleted the T1 COR volume
Deleted the brain COR volume
Deleted the flash5 COR volume

---- Creating symbolic links ----
Symbolic links to .surf files created in bem folder

Thank you for waiting.
The BEM triangulations for this subject are now available at:
/brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem.
We hope the BEM meshes created will facilitate your MEG and EEG data analyses.
Using surface: /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/inner_skull.surf
Using surface: /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/outer_skull.surf
Using surface: /brain/guixue/zhouyu/proj01/mri/freesurfer/recon_all/sub-41-1/bem/outer_skin.surf
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [21], in <cell line: 1>()
----> 1 mne.bem.make_flash_bem(subject, overwrite=False, show=True, subjects_dir=subjects_dir, flash_path=None, copy=False, verbose=None)

File <decorator-gen-76>:12, in make_flash_bem(subject, overwrite, show, subjects_dir, flash_path, copy, verbose)

File ~/.conda/envs/mne/lib/python3.9/site-packages/mne/bem.py:2003, in make_flash_bem(subject, overwrite, show, subjects_dir, flash_path, copy, verbose)
   2001 # Show computed BEM surfaces
   2002 if show:
-> 2003     plot_bem(subject=subject, subjects_dir=subjects_dir,
   2004              orientation='coronal', slices=None, show=True)

File ~/.conda/envs/mne/lib/python3.9/site-packages/mne/viz/misc.py:600, in plot_bem(subject, subjects_dir, orientation, slices, brain_surfaces, src, show, show_indices, mri, show_orientation)
    596     raise IOError('No surface files found. Surface files must end with '
    597                   'inner_skull.surf, outer_skull.surf or outer_skin.surf')
    599 # Plot the contours
--> 600 fig = _plot_mri_contours(
    601     mri_fname=mri_fname, surfaces=surfaces, src=src,
    602     orientation=orientation, slices=slices, show=show,
    603     show_indices=show_indices, show_orientation=show_orientation,
    604     slices_as_subplots=True
    605 )
    606 return fig

File ~/.conda/envs/mne/lib/python3.9/site-packages/mne/viz/misc.py:434, in _plot_mri_contours(mri_fname, surfaces, src, orientation, slices, show, show_indices, show_orientation, width, slices_as_subplots)
    432     with warnings.catch_warnings(record=True):  # ignore contour warn
    433         warnings.simplefilter('ignore')
--> 434         ax.tricontour(surf['rr'][:, x], surf['rr'][:, y],
    435                       surf['tris'], surf['rr'][:, axis],
    436                       levels=[sl], colors=color, linewidths=1.0,
    437                       zorder=1)
    439 if len(sources):
    440     in_slice = (sources[:, axis] >= lower) & (sources[:, axis] < upper)

File ~/.conda/envs/mne/lib/python3.9/site-packages/matplotlib/tri/tricontour.py:281, in tricontour(ax, *args, **kwargs)
    258 """
    259 %(_tricontour_doc)s
    260 
   (...)
    278     number of contour levels it will be repeated as necessary.
    279 """
    280 kwargs['filled'] = False
--> 281 return TriContourSet(ax, *args, **kwargs)

File ~/.conda/envs/mne/lib/python3.9/site-packages/matplotlib/tri/tricontour.py:29, in TriContourSet.__init__(self, ax, *args, **kwargs)
     19 def __init__(self, ax, *args, **kwargs):
     20     """
     21     Draw triangular grid contour lines or filled regions,
     22     depending on whether keyword arg 'filled' is False
   (...)
     27     are described in the docstring of `~.Axes.tricontour`.
     28     """
---> 29     super().__init__(ax, *args, **kwargs)

File ~/.conda/envs/mne/lib/python3.9/site-packages/matplotlib/contour.py:812, in ContourSet.__init__(self, ax, levels, filled, linewidths, linestyles, hatches, alpha, origin, extent, cmap, colors, norm, vmin, vmax, extend, antialiased, nchunk, locator, transform, *args, **kwargs)
    808     self.origin = mpl.rcParams['image.origin']
    810 self._transform = transform
--> 812 kwargs = self._process_args(*args, **kwargs)
    813 self._process_levels()
    815 self._extend_min = self.extend in ['min', 'both']

File ~/.conda/envs/mne/lib/python3.9/site-packages/matplotlib/tri/tricontour.py:45, in TriContourSet._process_args(self, *args, **kwargs)
     43 else:
     44     from matplotlib import _tri
---> 45     tri, z = self._contour_args(args, kwargs)
     46     C = _tri.TriContourGenerator(tri.get_cpp_triangulation(), z)
     47     self._mins = [tri.x.min(), tri.y.min()]

File ~/.conda/envs/mne/lib/python3.9/site-packages/matplotlib/tri/tricontour.py:72, in TriContourSet._contour_args(self, args, kwargs)
     69     raise ValueError('z must not contain masked points within the '
     70                      'triangulation')
     71 if not np.isfinite(z_check).all():
---> 72     raise ValueError('z array must not contain non-finite values '
     73                      'within the triangulation')
     75 z = np.ma.masked_invalid(z, copy=False)
     76 self.zmax = float(z_check.max())

ValueError: z array must not contain non-finite values within the triangulation

this image is not from a flash bem. The outer skull is still close to the skin.

Alex

1 Like

Yeah, youā€™re right. When I tried to compare the bem plot from watershed and flash, I found them exactly same. It turned out that the plot_bem used the watershed results which together with the flash results in the same subject bem folder. When I remove the watershed and flash bem results from the folder, and run mne.bem.make_flash_bem(subject, overwrite=False, show=True, subjects_dir=subjects_dir, flash_path=None, copy=False, verbose=None), the error message showed up which I posted above.

is there a way to access the data?

Alex

2 Likes

I tried Dropbox link, hope this work

these are DICOM files of the flash sequence

are you sure you have flash5 images? your image looks very different from the flash5 in
the MNE sample data

Alex

Could it be the way of processing the flash dicoms wrong or the flash sequence scanner parameters wrong? :flushed:
Because when I want to convert the flash dicoms following the MNE tutorials, like I said above the mne_organize_dicom: command not found and the future steps werenā€™t be continued so I tried other ways to process the flash images I posted above, Iā€™m not sure itā€™s the problem of the processing of the flash images or the original scanner parameters might be wrong?

can you try to convert the DICOM to a .nii or .mgz file using freesurfer?

look in the MNE sample dataset to see how the flash image should look like
in terms of contrast

Alex

1 Like

Sure, I can try that :ok_hand: In another hand, Iā€™m also considering using Fieldtrip to create the BEMs because I read about better reconstructions from Fieldtrip using T1 scans and not all of the subjects have the flash images, but I havenā€™t dug into it. Will it be trouble to use the BEM from Fieldtrip in MNE?