Skip to content

Commit

Permalink
update notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Shotgunosine committed Feb 2, 2024
1 parent 46415c8 commit fd200e7
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 28,724 deletions.
31 changes: 30 additions & 1 deletion notebooks/generate_and_evaluate_targets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"from nibabel import cifti2 as ci\n",
"from contarg.normgrid import load_liston_surfs, Surface\n",
"# from contarg.stimgrid import run_opt_and_save_outputs\n",
"from contarg.utils import graph_from_triangles, get_stimroi_path, surf_data_from_cifti, load_timeseries, SurfROI, cross_spearman\n",
"from contarg.utils import graph_from_triangles, get_stimroi_path, surf_data_from_cifti, load_timeseries, SurfROI, cross_spearman, replace_cifti_data\n",
"# from contarg.utils import get_stimroi_path, get_refroi_path, graph_from_triangles, , new_cifti_like, surf_data_from_cifti, cross_spearman, load_timeseries, find_bids_files, add_censor_columns, select_confounds, make_rel_symlink\n",
"from scipy import stats\n",
"from scipy.spatial.distance import pdist, cdist\n",
Expand Down Expand Up @@ -383,6 +383,35 @@
"]"
]
},
{
"cell_type": "markdown",
"source": [
"## This is the output you need for targeting"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"stim_stats_rev.sort_values('rep_rva_rank').loc[:, ses_comp_cols].head(10)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"## The rest of this coe is for comparing sessions"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 6,
Expand Down
113 changes: 68 additions & 45 deletions notebooks/prep_normgrid_targeting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
" setup_uncert_sims,\n",
" run_clusters,\n",
" calc_stimgrid,\n",
" make_uncert_sims\n",
" make_uncert_sims,\n",
" make_uncert_surfaces\n",
")"
]
},
Expand Down Expand Up @@ -740,20 +741,16 @@
" '--njobs',\n",
" f'20',\n",
" '--thresh-type=mt',\n",
" '--min-thresh=50',\n",
" '--max-thresh=80',\n",
" '--max-mt=80',\n",
" f'--min-thresh={mt_thresh}',\n",
" f'--max-thresh={maxMT}',\n",
" f'--max-mt={maxMT}',\n",
" ]\n",
" cmds.append(' '.join(cmd))"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "9179d2aa-aa4a-40cd-9703-1d148e943717",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
Expand All @@ -768,47 +765,14 @@
],
"source": [
"cmds[0]"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "4da24ca1-db3f-4da1-bab3-48d128aea1e9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!rm -rf /lscratch/$SLURM_JOB_ID/uncertsim-0"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b3a7af00-6223-4f66-b9d9-07beddcdcbc9",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[Parallel(n_jobs=20)]: Using backend LokyBackend with 20 concurrent workers.\n"
]
}
],
"source": [
"! {cmds[0]}"
]
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 28,
"id": "7959e330-0f81-4248-a1e0-731837b851ab",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
Expand All @@ -823,7 +787,10 @@
],
"source": [
"len(cmds)"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
Expand Down Expand Up @@ -909,6 +876,62 @@
" print(jobid)"
]
},
{
"cell_type": "markdown",
"source": [
" # Create surfaces from uncertainty sims"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"all_settings = []\n",
"for subject in subjects:\n",
" sim_dir = Path(anat_dir / f'sub-{subject}/Simulation/simulation-00')\n",
" if not sim_dir.exists():\n",
" sim_dir = Path(anat_dir / f'sub-{subject}/Simulation/simulation-01')\n",
" if not sim_dir.exists():\n",
" print(f\"{sim_dir} not found, skipping\")\n",
" uncert_dir = sim_dir / f'uncert{nsims}'\n",
" settings_path = uncert_dir / 'settings.pkl.gz'\n",
" all_settings.append(settings_path)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"\n",
"jobs = []\n",
"for (subject, settings_path) in zip(subjects, all_settings):\n",
" src_surf_dir = liston_root / f'sub-{subject}/anat/T1w/fsaverage_LR32k/'\n",
" uncert_dir = settings_path.parent\n",
" jobs.append(delayed(make_uncert_surfaces)(subject, src_surf_dir, uncert_dir, overwrite=True))\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"Parallel(n_jobs=10, verbose=10)(jobs)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"id": "f7a03ef7-64be-4f5d-86f0-bce215da0d7d",
Expand Down
Loading

0 comments on commit fd200e7

Please sign in to comment.