[Simnibs-discuss] Question about the Scripting Simulations/Optimizations

Guilherme B Saturnino guilhermebs at drcmr.dk
Wed Mar 4 09:28:23 CET 2020


Dear Dr. Zama,


Thank you for your interest and for reporting the issue!


On 04/03/2020 02.37, Takuro ZAMA wrote:
> Dear Dr. Saturnino,
>
> Thank you for your speedy handling and advice.
> I am so excited to use the new version.
> I will try it soon, and keep the channelnr variable unset.
>
> I sincerely appreciate your kind support.
> From next time, I will post to the public mailing list.
>
> Best regards,
> Takuro
>
> On 2020/03/03 22:15, Guilherme B Saturnino wrote:
>> Dear Dr. Zama,
>>
>>
>> There was a problem in setting up the leadfields with 2-layer 
>> electrodes. Thanks a lot for pointing this out. We just released 
>> version 3.1.2 with a fix.
>>
>> Even thought the problem was not with "channelnr", I would still like 
>> to strongly advise you to keep this variable unset.
>>
>>
>> Best Regards,
>>
>> Guilherme
>>
>>
>>
>>
>> 28/02/2020 17.23, Takuro ZAMA wrote:
>>
>>> Dear Dr. Saturnino,
>>>
>>> Thank you for your information. I got it about the function of the 
>>> "channelnr" option.
>>> I commented out that lines to unset "channelnr".
>>> However, I still get same error as follows:
>>> --------------
>>> [ simnibs ]CRITICAL: Uncaught exception
>>> Traceback (most recent call last):
>>>   File 
>>> "c:\Users\zama\AppData\Local\SimNIBS\miniconda3\envs\simnibs_env\lib\site-packages\simnibs\simulation\cond.py", 
>>> line 154, in test_numerical
>>>     c = float(v)
>>> TypeError: float() argument must be a string or a number, not 
>>> 'NoneType'
>>>
>>> During handling of the above exception, another exception occurred:
>>>
>>> TypeError: The value 100 in cond_list is not numerical
>>> ------------------
>>>
>>> Do you have any other idea?
>>>
>>> Best regards,
>>> Takuro
>>>
>>>
>>>
>>> On 2020/02/28 17:44, Guilherme B Saturnino wrote:
>>>> Dear Dr. Zama,
>>>>
>>>>
>>>> Thanks for sending the script.
>>>>
>>>> I see you are setting all "channelnr" to 2 in line 74 and "1" in 
>>>> line 90. Please remove this lines and just leave "channelnr" unset. 
>>>> This option basically says which electrodes should be 
>>>> "short-circuited" together, and it is very tricky to use it in tDCS 
>>>> optimization. We might just remove this option in a near future.
>>>>
>>>>
>>>> Best Regards,
>>>>
>>>> Guilherme
>>>>
>>>>
>>>> On 27/02/2020 06.48, Takuro ZAMA wrote:
>>>>> Dear Dr. Saturnino,
>>>>>
>>>>> Thank you for your kind support.
>>>>>
>>>>>>> It depends. The one in the link I sent you is. But the one in 
>>>>>>> m2m_subID/eeg_positions/ is in subject spaece
>>>>> I am sorry for not explaining sufficiently.
>>>>> This is consistent with my perception.
>>>>>
>>>>>>> Could you please send me your script?
>>>>> Sure. Please find the attached as .txt and .m files.
>>>>>
>>>>> Best regards,
>>>>> Takuro
>>>>>
>>>>> On 2020/02/25 20:47, Guilherme B Saturnino wrote:
>>>>>> Dear Dr. Zama,
>>>>>>
>>>>>>
>>>>>> Thanks a lot for the feedback and to allow us to publish this 
>>>>>> exchange.
>>>>>>
>>>>>> /In "EEG10-10_UI_Jurak_2007.csv", the position is described in 
>>>>>> the MNI coordinate system, right?
>>>>>> /
>>>>>>
>>>>>> /
>>>>>> /
>>>>>>
>>>>>> It depends. The one in the link I sent you is. But the one in 
>>>>>> m2m_subID/eeg_positions/ is in subject spaece
>>>>>>
>>>>>> /
>>>>>> //In "EEG10-10_UI_Jurak_2007.csv", the position is described in 
>>>>>> the MNI coordinate system, right? //
>>>>>> //It seems we have no choice but to translate the cheek position 
>>>>>> in subject space to MNI space via "subject2mni_coords" . //
>>>>>> //For your information, I processed with the following steps: //
>>>>>> //1) I decided cheek position visually for each subject (N = 5). //
>>>>>> //2) I translated the position to MNI space and averaged. //
>>>>>> //3) I added the averaged MNI position to the CSV file as a new 
>>>>>> electrode. /
>>>>>>
>>>>>>
>>>>>> I think this makes a lot of sense
>>>>>>
>>>>>>
>>>>>> /
>>>>>> //I have new question about the optimization. //
>>>>>> //Now, I am trying to change the electrode setting (e.g., shape, 
>>>>>> size). //
>>>>>> //I prepared the tdcs_lf.electrode(1)~tdcs_lf.electrode(N). //
>>>>>> //N means the number of all electrodes except the "Fiducial". //
>>>>>> //These had following fields: //
>>>>>> //- channelnr //
>>>>>> //- dimensions //
>>>>>> //- shape //
>>>>>> //- thickness //
>>>>>> //- centre //
>>>>>> //- pos_ydir //
>>>>>> //- plug.shape //
>>>>>> //- plug.dimensions //
>>>>>> //- plug.centre //
>>>>>> ////
>>>>>> //The examples of the result of placeing electrode are 
>>>>>> follows:--------------- //
>>>>>> //… //
>>>>>> //[ simnibs ]INFO: Placing Electrode: //
>>>>>> //definition: plane //
>>>>>> //shape: ellipse //
>>>>>> //centre: [ 20.1864 -80.4478 -38.9034] //
>>>>>> //pos_ydir: [] //
>>>>>> //dimensions: [20, 20] //
>>>>>> //thickness:[5, 2] //
>>>>>> //channelnr: 76 //
>>>>>> //number of holes: 0 //
>>>>>> ////
>>>>>> //[ simnibs ]INFO: Placing Electrode: //
>>>>>> //definition: plane //
>>>>>> //shape: rect //
>>>>>> //centre: [-45.0869  81.2591 -41.0414] //
>>>>>> //pos_ydir: [] //
>>>>>> //dimensions: [50, 50] //
>>>>>> //thickness:[5, 2] //
>>>>>> //channelnr: 77 //
>>>>>> //number of holes: 0 //
>>>>>> //… //
>>>>>> //-------------------------- //
>>>>>> ////
>>>>>> //After the "[ simnibs ]INFO: Using isotropic conductivities", 
>>>>>> program output following error:------------------------ //
>>>>>> //[ simnibs ]CRITICAL: Uncaught exception //
>>>>>> //Traceback (most recent call last): //
>>>>>> //  File "SIMNIBSDIR\simulation\cond.py", line 154, in 
>>>>>> test_numerical //
>>>>>> //    c = float(v) //
>>>>>> //TypeError: float() argument must be a string or a number, not 
>>>>>> 'NoneType' //
>>>>>> //During handling of the above exception, another exception 
>>>>>> occurred: //
>>>>>> //TypeError: The value 100 in cond_list is not numerical //
>>>>>> //-------------------- //
>>>>>> ////
>>>>>> //Do you have any idea about this error? //
>>>>>> //My electrode setting is wrong? /
>>>>>>
>>>>>>
>>>>>> Could you please send me your script?
>>>>>>
>>>>>>
>>>>>> Best Regards,
>>>>>>
>>>>>> Guilherme
>>>>>>
>>>>>> On 25/02/2020 04.22, Takuro ZAMA wrote:
>>>>>>> Dear Dr. Saturnino,
>>>>>>>
>>>>>>> I am sorry for the late response. I was trying what you told me.
>>>>>>> Thanks to your support, the simulation and optimization worked 
>>>>>>> well!
>>>>>>> Sure, please publish this discussion in the public mailing list.
>>>>>>>
>>>>>>> In "EEG10-10_UI_Jurak_2007.csv", the position is described in 
>>>>>>> the MNI coordinate system, right?
>>>>>>> It seems we have no choice but to translate the cheek position 
>>>>>>> in subject space to MNI space via "subject2mni_coords" .
>>>>>>> For your information, I processed with the following steps:
>>>>>>> 1) I decided cheek position visually for each subject (N = 5).
>>>>>>> 2) I translated the position to MNI space and averaged.
>>>>>>> 3) I added the averaged MNI position to the CSV file as a new 
>>>>>>> electrode.
>>>>>>>
>>>>>>> I have new question about the optimization.
>>>>>>> Now, I am trying to change the electrode setting (e.g., shape, 
>>>>>>> size).
>>>>>>> I prepared the tdcs_lf.electrode(1)~tdcs_lf.electrode(N).
>>>>>>> N means the number of all electrodes except the "Fiducial".
>>>>>>> These had following fields:
>>>>>>> - channelnr
>>>>>>> - dimensions
>>>>>>> - shape
>>>>>>> - thickness
>>>>>>> - centre
>>>>>>> - pos_ydir
>>>>>>> - plug.shape
>>>>>>> - plug.dimensions
>>>>>>> - plug.centre
>>>>>>>
>>>>>>> The examples of the result of placeing electrode are 
>>>>>>> follows:---------------
>>>>>>>>>>>>>> [ simnibs ]INFO: Placing Electrode:
>>>>>>> definition: plane
>>>>>>> shape: ellipse
>>>>>>> centre: [ 20.1864 -80.4478 -38.9034]
>>>>>>> pos_ydir: []
>>>>>>> dimensions: [20, 20]
>>>>>>> thickness:[5, 2]
>>>>>>> channelnr: 76
>>>>>>> number of holes: 0
>>>>>>>
>>>>>>> [ simnibs ]INFO: Placing Electrode:
>>>>>>> definition: plane
>>>>>>> shape: rect
>>>>>>> centre: [-45.0869  81.2591 -41.0414]
>>>>>>> pos_ydir: []
>>>>>>> dimensions: [50, 50]
>>>>>>> thickness:[5, 2]
>>>>>>> channelnr: 77
>>>>>>> number of holes: 0
>>>>>>>>>>>>>> --------------------------
>>>>>>>
>>>>>>> After the "[ simnibs ]INFO: Using isotropic conductivities", 
>>>>>>> program output following error:------------------------
>>>>>>> [ simnibs ]CRITICAL: Uncaught exception
>>>>>>> Traceback (most recent call last):
>>>>>>>   File "SIMNIBSDIR\simulation\cond.py", line 154, in test_numerical
>>>>>>>     c = float(v)
>>>>>>> TypeError: float() argument must be a string or a number, not 
>>>>>>> 'NoneType'
>>>>>>> During handling of the above exception, another exception occurred:
>>>>>>> TypeError: The value 100 in cond_list is not numerical
>>>>>>> --------------------
>>>>>>>
>>>>>>> Do you have any idea about this error?
>>>>>>> My electrode setting is wrong?
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Takuro Zama
>>>>>>>
>>>>>>> On 2020/02/20 22:22, Guilherme B Saturnino wrote:
>>>>>>>> Dear Dr. Zama,
>>>>>>>>
>>>>>>>>
>>>>>>>> Thank you for your interest in SimNIBS!
>>>>>>>>
>>>>>>>>
>>>>>>>> 1. Yes, you can. I think the best way to do this is to define 
>>>>>>>> another electrode cap ".csv" file with the additional positions 
>>>>>>>> you want. You can either:
>>>>>>>>
>>>>>>>> A) Add the new position to the file 
>>>>>>>> m2m_subID/eeg_positions/EEG10-10_UI_Jurak_2007.csv
>>>>>>>>
>>>>>>>> B) Download this file 
>>>>>>>> <https://raw.githubusercontent.com/simnibs/simnibs/master/simnibs/resources/ElectrodeCaps_MNI/EEG10-10_UI_Jurak_2007.csv>, 
>>>>>>>> modify it to add the new electrode,  and run the 
>>>>>>>> mni2subject_coords 
>>>>>>>> <https://simnibs.github.io/simnibs/build/html/documentation/command_line/mni2subject_coords.html> 
>>>>>>>> command line tool to bring the eeg positions to subject space. 
>>>>>>>> Afterwards, when running the leadfield, add /leadfield.eeg_cap 
>>>>>>>> = 'path/to/cap.csv'/
>>>>>>>>
>>>>>>>> 2. Yes, this would be the constraint on the number of 
>>>>>>>> electrodes. Just set for example /opt.max_active_electrodes = 
>>>>>>>> 2//./
>>>>>>>>
>>>>>>>> 3. Yes, you need to define cheek positions in MNI space and 
>>>>>>>> follow the instructions (1B) above.
>>>>>>>>
>>>>>>>>
>>>>>>>> Best Regards,
>>>>>>>>
>>>>>>>> Guilherme Saturnino
>>>>>>>>
>>>>>>>>
>>>>>>>> I feel other people could also benefit from this discussion. 
>>>>>>>> Can I publish it in our public mailing list?
>>>>>>>>
>>>>>>>> On 20/02/2020 11.34, Takuro ZAMA wrote:
>>>>>>>>> Dear Sir or Madam,
>>>>>>>>>
>>>>>>>>> I am Takuro Zama, and a research scientist at the RIKEN in Japan.
>>>>>>>>> I have started to use the simNIBS for tES. Thank you for the 
>>>>>>>>> wonderful tool!
>>>>>>>>>
>>>>>>>>> I am trying to reconstruct mesh images using T1- and T2-images 
>>>>>>>>> with "headreco" and to simulate tES for each subject.
>>>>>>>>> The return electrode position is considering the cheek 
>>>>>>>>> position, and I would like to optimize where the electrodes 
>>>>>>>>> should be placed to stimulate the specified brain region.
>>>>>>>>> I have following questions about the Scripting:
>>>>>>>>>
>>>>>>>>> 1. Can I use a extracephalic position in optimization?
>>>>>>>>> Sometimes, a return electrode of tES is set on a extracephalic 
>>>>>>>>> position such as cheek.
>>>>>>>>> Since I am considering EEG measurement during tDCS, I also 
>>>>>>>>> would like to put the return electrode on the cheek to keep 
>>>>>>>>> the number of EEG electrodes.
>>>>>>>>> Can I optimize the electrodes position taking into account the 
>>>>>>>>> cheek position?
>>>>>>>>>
>>>>>>>>> 2. Can optimization output only one pair of electrodes?
>>>>>>>>> If I perform optimization based on the electrode arrangement 
>>>>>>>>> of EEG10-10_UI_Jurak_2007, I can get the combination of 
>>>>>>>>> multiple electrodes.
>>>>>>>>> I would like to get pair, which is optimized by 2 electrodes, 
>>>>>>>>> because I use 2 electrodes for stimulation.
>>>>>>>>> Is the optimization just a suggestion and is the simulation, 
>>>>>>>>> which is based on the optimization result, recommended 
>>>>>>>>> eventually?
>>>>>>>>>
>>>>>>>>> 3. Can I get a coordinates of cheek position automatically?
>>>>>>>>> When run a simulation with cheek position, I would like to 
>>>>>>>>> determine the coordinates of the cheek position based on 
>>>>>>>>> specific criteria like the EEG10-10 electrode.
>>>>>>>>> However, cheek coordinates are not included in "m2m_subID / 
>>>>>>>>> eeg_positions / EEG10-10_UI_Jurak_2007.csv" which is 
>>>>>>>>> automatically calculated by "haedreco".
>>>>>>>>> Is there any way to get automatically the cheek coordinates on 
>>>>>>>>> the subject-space?
>>>>>>>>> If I can do that, the simulation in CUI will be more comfortable.
>>>>>>>>>
>>>>>>>>> Yours faithfully,
>>>>>>>>> Takuro Zama
>>>>>
>>>
>


More information about the Simnibs-discuss mailing list