diff --git a/notebooks/03_prep_normgrid_targeting.ipynb b/notebooks/03_prep_normgrid_targeting.ipynb index 6217f8c..cd6c121 100644 --- a/notebooks/03_prep_normgrid_targeting.ipynb +++ b/notebooks/03_prep_normgrid_targeting.ipynb @@ -34,6 +34,7 @@ "import seaborn as sns\n", "import networkx as nx\n", "from simnibs import opt_struct\n", + "from simnibs.utils.nnav import brainsight\n", "from joblib import Parallel, delayed\n", "import templateflow\n", "import subprocess\n", @@ -403,10 +404,57 @@ "collapsed": false } }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "def get_optmat(row):\n", + " opt_top = np.vstack([row.bxv, row.byv, row.bzv, np.array([row.bx, row.by, row.bz])]).T\n", + " opt = np.vstack([opt_top, np.array([[0,0,0,1]])])\n", + " return opt" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "for subject in subjects:\n", + " src_surf_dir = liston_root / f'sub-{subject}/anat/T1w/fsaverage_LR32k/'\n", + " headmodel_dir = anat_dir /f'sub-{subject}/HeadModel'\n", + " sim_out_dir = anat_dir / f'sub-{subject}/Simulation'\n", + " sim_dir = sorted(sim_out_dir.glob('simulation-*'))[-1]\n", + " for session in [1]:\n", + " for smoothing in [2.55]:\n", + " bs_targ_path = sim_dir / f'sub-{subject}_ses-{session}_smoothing-{smoothing}_brainsighttarget.txt'\n", + " bs = brainsight()\n", + " row = stim_stats_rev.query('subject == @subject & session == @session & smoothing == @smoothing & rep_rva_rank == 1').iloc[0]\n", + " optmat = get_optmat(row)\n", + " bs.write(optmat, bs_targ_path.as_posix(), overwrite=True)" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": null, + "outputs": [], + "source": [ + "_ = [print(foo) for foo in bs_targ_path.read_text().split('\\n')]" + ], + "metadata": { + "collapsed": false + } + }, { "cell_type": "markdown", "source": [ - "## The rest of this coe is for comparing sessions" + "## The rest of this code is for comparing sessions" ], "metadata": { "collapsed": false