Skip to content

Commit

Permalink
add brainsight outupt
Browse files Browse the repository at this point in the history
  • Loading branch information
Shotgunosine committed Feb 2, 2024
1 parent 17fb4b9 commit 8c1ebf5
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion notebooks/03_prep_normgrid_targeting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8c1ebf5

Please sign in to comment.