<div dir="ltr"><div>Hello SimNIBS Team, </div><div><br></div><div><div>I am attempting to export my TMS Optimization results (estimated via the ADM method) to a Brainsight-readable .xml file, but I am getting the following error when I try to execute <font color="#cc0000">brainsight().write(opt_mat, fn)</font></div> <p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">[ simnibs ]CRITICAL: Uncaught exception</span></p><p style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;margin:0px;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">AssertionError: Expecting array with shape (4, 4, N instrument marker).</span></p><div><br></div><div>As you can see in the following python script (appended below), I am using a standard set of arguments to set up my optimization routine, so I don't know why the export function isn't working. Everything seems to function properly up until the brainsight().write call. Would you please help me address this issue?</div><div><br></div><div>Note that the optimization itself appears to execute without error. Also, FWIW, I am running on Mac OS Big Sur 11.7, and I just recently installed my version of SimNIBS (last week).</div><div><br class="gmail-Apple-interchange-newline">Thank you,<br>Andrew<br></div><div><br></div><div>===</div><div><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">import os
import sys</pre><pre class="gmail-aLF-aPX-K0-aPE" style="font-family:"Courier New",Courier,monospace,arial,sans-serif;margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);font-size:14px">from simnibs import sim_struct, opt_struct, brainsight, mni2subject_coords
fn = "precomputed_coilpos.xml"

### export from np.ndarray / matsimnibs
tms_opt = opt_struct.TMSoptimize()
# ... prepare optmization ...
# Subject folder
tms_opt.subpath = 'm2m_105'
# Select output folder
tms_opt.pathfem = 'tms_optimization_adm'
# Select the coil model
# The ADM method requires a '.ccd' coil model
tms_opt.fnamecoil = os.path.join('legacy_and_other','Magstim_70mm_Fig8.ccd')
# Select a target for the optimization and other params
tms_opt.target = mni2subject_coords([-42, 13, 33], 'm2m_105')
tms_opt.distance = 6.0 # mm 
# Use the ADM method
tms_opt.method = 'ADM'
tms_opt.open_in_gmsh = False
opt_mat = tms_opt.run() # get optimal position

brainsight().write(opt_mat, fn)</pre></div><div><br></div><div>===</div><div><br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:small">Andrew Westbrook</div><div style="font-size:small"><br></div><div style="font-size:small">Post-Doctoral Research Associate</div><div style="font-size:small">Department of Cognitive, Linguistics, and Psychological Sciences</div><div style="font-size:small">Brown University<br></div><div style="font-size:small">190 Thayer Street</div><div style="font-size:small"><div>Providence, RI 02912</div></div><div style="font-size:small">Cell: +1-919-360-5399<br><br></div></div></div></div></div></div></div></div>