Skip to content

Commit

Permalink
Initial go at updating notebooks to use the logger we're calling caiman
Browse files Browse the repository at this point in the history
  • Loading branch information
pgunn committed Jul 24, 2024
1 parent b3fafb5 commit d3a89fc
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 50 deletions.
14 changes: 10 additions & 4 deletions demos/notebooks/demo_OnACID_mesoscope.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@
"from caiman.source_extraction import cnmf\n",
"from caiman.utils.utils import download_demo\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.INFO)\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.INFO)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"logger.addHandler(handler)\n",
"\n",
"try:\n",
" if __IPYTHON__:\n",
Expand Down
14 changes: 10 additions & 4 deletions demos/notebooks/demo_Ring_CNN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@
"import numpy as np\n",
"import os\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.WARNING)\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.INFO)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"logger.addHandler(handler)\n",
"\n",
"import caiman as cm\n",
"import caiman.base.movies\n",
Expand Down
14 changes: 10 additions & 4 deletions demos/notebooks/demo_VST.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@
"import os\n",
"import timeit\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.DEBUG)\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.INFO)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"logger.addHandler(handler)\n",
"\n",
"import caiman.external.houghvst.estimation as est\n",
"from caiman.external.houghvst.gat import compute_gat, compute_inverse_gat\n",
Expand Down
13 changes: 9 additions & 4 deletions demos/notebooks/demo_caiman_cnmf_3D.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@
"import bokeh.plotting as bpl\n",
"bpl.output_notebook()\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.WARNING)"
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.INFO)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n"
]
},
{
Expand Down
12 changes: 8 additions & 4 deletions demos/notebooks/demo_dendritic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@
" print(f\"Will save logging data to {log_file}\")\n",
"else:\n",
" log_file = None\n",
"log_format = \"{asctime} - {levelname} - [{filename} {funcName}() {lineno}] - pid {process} - {message}\"\n",
"logging.basicConfig(format=log_format,\n",
" filename=log_file, \n",
" level=logging.WARNING, style=\"{\") #DEBUG, INFO, WARNING, ERROR, CRITICAL"
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.INFO)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if log_file is not None:\n",
" handler = logging.FileHandler(log_file)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n"
]
},
{
Expand Down
13 changes: 9 additions & 4 deletions demos/notebooks/demo_motion_correction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@
"except NameError:\n",
" pass\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.DEBUG)\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.INFO)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"\n",
"import caiman as cm\n",
"from caiman.motion_correction import MotionCorrect, tile_and_correct, motion_correction_piecewise\n",
Expand Down
13 changes: 9 additions & 4 deletions demos/notebooks/demo_online_3D.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@
"import bokeh.plotting as bpl\n",
"bpl.output_notebook()\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.WARNING)"
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.WARNING)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n"
]
},
{
Expand Down
13 changes: 9 additions & 4 deletions demos/notebooks/demo_online_cnmfE.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@
"except NameError:\n",
" pass\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)10s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.WARNING)\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.WARNING)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"\n",
"bpl.output_notebook()\n",
"hv.notebook_extension('bokeh')"
Expand Down
12 changes: 9 additions & 3 deletions demos/notebooks/demo_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,15 @@
"outputs": [],
"source": [
"# set up logging\n",
"logging.basicConfig(format=\"{asctime} - {levelname} - [{filename} {funcName}() {lineno}] - pid {process} - {message}\",\n",
" filename=None, \n",
" level=logging.WARNING, style=\"{\") #logging level can be DEBUG, INFO, WARNING, ERROR, CRITICAL\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.WARNING)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"\n",
"# set env variables \n",
"os.environ[\"MKL_NUM_THREADS\"] = \"1\"\n",
Expand Down
12 changes: 9 additions & 3 deletions demos/notebooks/demo_pipeline_cnmfE.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,15 @@
"outputs": [],
"source": [
"# set up logging\n",
"logging.basicConfig(format=\"{asctime} - {levelname} - [{filename} {funcName}() {lineno}] - pid {process} - {message}\",\n",
" filename=None, \n",
" level=logging.WARNING, style=\"{\") #logging level can be DEBUG, INFO, WARNING, ERROR, CRITICAL\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.WARNING)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"\n",
"# set env variables in case they weren't already set\n",
"os.environ[\"MKL_NUM_THREADS\"] = \"1\"\n",
Expand Down
13 changes: 9 additions & 4 deletions demos/notebooks/demo_pipeline_voltage_imaging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@
"from caiman.summary_images import mean_image\n",
"from caiman.paths import caiman_datadir\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s]\" \\\n",
" \"[%(process)d] %(message)s\",\n",
" level=logging.ERROR)"
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.ERROR)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n"
]
},
{
Expand Down
13 changes: 9 additions & 4 deletions demos/notebooks/demo_realtime_cnmfE.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@
"except NameError:\n",
" pass\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)10s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.WARNING)\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.WARNING)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"\n",
"import caiman as cm\n",
"from caiman.source_extraction import cnmf\n",
Expand Down
13 changes: 9 additions & 4 deletions demos/notebooks/demo_seeded_CNMF.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@
"except NameError:\n",
" pass\n",
"\n",
"logging.basicConfig(format=\n",
" \"%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s\",\n",
" # filename=\"/tmp/caiman.log\",\n",
" level=logging.WARNING)\n",
"logfile = None # Replace with a path if you want to log to a file\n",
"logger = logging.getLogger('caiman')\n",
"logger.setLevel(logging.WARNING)\n",
"logfmt = '%(relativeCreated)12d [%(filename)s:%(funcName)20s():%(lineno)s] [%(process)d] %(message)s'\n",
"if logfile is not None:\n",
" handler = logging.FileHandler(logfile)\n",
"else:\n",
" handler = logging.StreamHandler()\n",
"handler.setFormatter(logfmt)\n",
"\n",
"import caiman as cm\n",
"from caiman.motion_correction import MotionCorrect\n",
Expand Down

0 comments on commit d3a89fc

Please sign in to comment.