{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "Accessing and sharing data with ONE local mode", "provenance": [] }, "kernelspec": { "name": "python3", "language": "python", "display_name": "Python 3 (ipykernel)" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "Ke27mmuJ_i0R" }, "source": [ "# Recording data access\n", "When working with huge data repositories it can be worthwhile to record the subset of data used\n", "for a given analysis. ONE can keep track of which datasets were loaded via the `load_*` methods.\n", "\n", "Only datasets that were successfully loaded are recorded; missing datasets are ignored.\n", "\n", "## How to set up and save\n", "At the top of your analysis script, after instantiating ONE, simply set the `record_loaded`\n", "attribute to True:\n", "```python\n", "one.record_loaded = True\n", "```\n", "\n", "At the end of your analysis script, you can save the data by calling `one.save_loaded_ids()`.\n", "By default this will save the dataset UUIDs to a CSV file in the root of your cache directory\n", "and will clear the list of dataset UUIDs. The `sessions_only` kwarg will save the\n", "[eids](./experiment_ids) instead.\n", "\n", "
\n", "Note.\n", "\n", "Within a Python session, calling ONE again with the same arguments (from any location) will return\n", "the previous object, therefore if you want to stop recording dataset UUIDs you must explicitly set\n", "`record_loaded` to False, e.g. `ONE().record_loaded = False`.\n", "
\n", "\n", "## Example" ] }, { "cell_type": "code", "execution_count": 1, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "F:\\FlatIron\\openalyx.internationalbrainlab.org\\2022-02-24T13-37-07_loaded_dataset_uuids.csv\n", " dataset_uuid\n", "0 0bc9607d-0a72-4c5c-8b9d-e239a575ff67\n", "1 16c81eaf-a032-49cd-9823-09c0c7350fd2\n", "2 2f4cc220-55b9-4fb3-9692-9aaa5362288f\n", "3 4ee1110f-3ff3-4e26-87b0-41b687f75ce3\n", "4 63aa7dea-1ee2-4a0c-88bc-00b5cba6b8b0\n", "5 69236a5d-1e4a-4bea-85e9-704492756848\n", "6 6b94f568-9bb6-417c-9423-a84559f403d5\n", "7 82237144-41bb-4e7f-9ef4-cabda4381d9f\n", "8 91f08c6d-7ee0-487e-adf5-9c751769af06\n", "9 b77d2665-876e-41e7-ac57-aa2854c5d5cd\n", "10 c14d8683-3706-4e44-a8d2-cd0e2bfd4579\n", "11 c8cd43a7-b443-4342-8c37-aa93a2067447\n", "12 d078bfc8-214d-4682-8621-390ad74dd6d5\n", "13 d11d7b33-3a96-4ea6-849f-5448a97d3fc1\n", "14 d73f567a-5799-4051-9bc8-6f0fd6bb478b\n", "15 e1793e9d-cd96-4cb6-9fd7-a6b662c41971\n", "16 fceb8cfe-77b4-4177-a6af-44fbf51b33d0\n", "\n", "F:\\FlatIron\\openalyx.internationalbrainlab.org\\2022-02-24T13-37-07_loaded_session_uuids.csv\n", " session_uuid\n", "0 4b7fbad4-f6de-43b4-9b15-c7c7ef44db4b\n", "1 aad23144-0e52-4eac-80c5-c4ee2decb198\n" ] } ], "source": [ "import pandas as pd\n", "from one.api import ONE\n", "one = ONE(base_url='https://openalyx.internationalbrainlab.org')\n", "\n", "# Turn on recording of loaded dataset UUIDs\n", "one.record_loaded = True\n", "\n", "# Load some trials data\n", "eid = 'KS023/2019-12-10/001'\n", "dsets = one.load_object(eid, 'trials')\n", "\n", "# Load another dataset\n", "eid = 'CSHL049/2020-01-08/001'\n", "dset = one.load_dataset(eid, 'probes.description')\n", "\n", "# Save the dataset IDs to file\n", "dataset_uuids, filename = one.save_loaded_ids(clear_list=False)\n", "print(filename)\n", "print(pd.read_csv(filename), end='\\n\\n')\n", "\n", "# Save the session IDs\n", "session_uuids, filename = one.save_loaded_ids(sessions_only=True)\n", "print(filename)\n", "print(pd.read_csv(filename))\n" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } } ] }