{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "a42c36bb-6436-4225-aef0-e0396d3fb323", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "importing modules\n" ] } ], "source": [ "print(\"importing modules\")\n", "import os\n", "import sys\n", "import json\n", "import argparse\n", "import numpy as np\n", "import time\n", "import random\n", "import string\n", "import h5py\n", "from tqdm import tqdm\n", "import webdataset as wds\n", "from PIL import Image\n", "import pandas as pd\n", "import nibabel as nib\n", "import nilearn\n", "\n", "import matplotlib.pyplot as plt\n", "import torch\n", "import torch.nn as nn\n", "from torchvision import transforms\n", "\n", "# tf32 data type is faster than standard float32\n", "torch.backends.cuda.matmul.allow_tf32 = True\n", "\n", "import utils\n", "from utils import load_preprocess_betas, resample, applyxfm, apply_thresh, resample_betas\n", "\n", "# imports utils from mindeye_preproc as \"preproc\"\n", "import importlib.util\n", "parent_utils_path = \"/home/ri4541/mindeye_preproc/analysis/utils.py\"\n", "spec = importlib.util.spec_from_file_location(\"utils\", parent_utils_path)\n", "preproc = importlib.util.module_from_spec(spec)\n", "parent_dir = os.path.dirname(parent_utils_path)\n", "if parent_dir not in sys.path:\n", " sys.path.append(parent_dir)\n", "spec.loader.exec_module(preproc)\n", "\n", "if utils.is_interactive():\n", " from IPython.display import clear_output # function to clear print outputs in cell\n", " %load_ext autoreload \n", " # this allows you to change functions in models.py or utils.py and have this notebook automatically update with your revisions\n", " %autoreload 2 " ] }, { "cell_type": "code", "execution_count": null, "id": "6a697e85-f2fe-473a-9ce0-fb4f2ffc3622", "metadata": {}, "outputs": [], "source": [ "sub = 'sub-001'\n", "session = 'ses-05'\n", "tasks = ['A', 'B', 'C']\n", "split = 'MST' # train/test split should be MST for multi-protocol experiments\n", "n_seeds = 10" ] }, { "cell_type": "code", "execution_count": null, "id": "f00cab3e-0d92-4205-8273-f8961f08f4fe", "metadata": {}, "outputs": [], "source": [ "import ast # safe evaluation of limited python data types\n", "\n", "all_evals = []\n", "for i in range(10):\n", " evals = []\n", " model_name=f\"{sub}_{session}_task-{task}_bs24_MST_rishab_{split}split_{i}\"\n", " eval_dir = f\"/scratch/gpfs/ri4541/MindEyeV2/src/mindeyev2/evals/{model_name}\"\n", " with open(f\"{eval_dir}/final_evals\", 'r') as f:\n", " # skip the first two lines - no useful info\n", " f.readline(); f.readline()\n", " for line in f: # pixcorr, ssim, alexnet2, alexnet5, inception, clip_, effnet, swav, fwd_acc, bwd_acc, mst_score\n", " # print(line.strip())\n", " evals.append(ast.literal_eval(line.strip())) # strip() gets rid of leading and trailing spaces/newlines; literal_eval() returns the values as the \"intended\" type instead of strings\n", " # evals.append(line.strip())\n", " all_evals.append(evals)\n", "\n", "all_evals[0]" ] } ], "metadata": { "kernelspec": { "display_name": "rt_mindEye2 [~/.conda/envs/rt_mindEye2/]", "language": "python", "name": "conda_rt_mindeye2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }