From 63d50808c4c7e97bdfc89076cb19af9e13252057 Mon Sep 17 00:00:00 2001 From: Kay Robbins <1189050+VisLab@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:09:31 -0500 Subject: [PATCH] Updated documentation for change in remodeling backup CLI args --- docs/source/FileRemodelingTools.md | 18 +- .../remodeling/run_remodel.ipynb | 114 +++++++++--- .../remodeling/run_remodel_backup.ipynb | 89 +++++---- .../data_cleaning/runEeglabImportEvents.m | 169 +++++++++--------- .../data_cleaning/runEeglabImportEventsOld.m | 88 +++++++++ .../matlab_scripts/web_services/runAllTests.m | 2 +- hedcode/matlab_scripts/web_services/runTest.m | 2 +- .../web_services/testEventSearchServices.m | 30 ++-- 8 files changed, 348 insertions(+), 164 deletions(-) create mode 100644 hedcode/matlab_scripts/data_cleaning/runEeglabImportEventsOld.m diff --git a/docs/source/FileRemodelingTools.md b/docs/source/FileRemodelingTools.md index 5f451332..24f63bf3 100644 --- a/docs/source/FileRemodelingTools.md +++ b/docs/source/FileRemodelingTools.md @@ -236,9 +236,9 @@ The programs use a standard command-line argument list for specifying input as s ````{table} Summary of command-line arguments for the remodeling programs. | Script name | Arguments | Purpose | | ----------- | -------- | ------- | -|*run_remodel_backup* | *data_dir*
*-e -\\-extensions*
*-f -\\-file-suffix*
*-n -\\-backup-name*
*-t -\\-task-names*
*-v -\\-verbose*
*-w -\\-work-dir*
*-x -\\-exclude-dirs*| Create a backup event files. | -|*run_remodel* | *data_dir*
*model_path*
*-b -\\-bids-format*
*-e -\\-extensions*
*-f -\\-file-suffix*
*-i -\\-individual-summaries*
*-j -\\-json-sidecar*
*-n -\\-backup-name*
*-nb -\\-no-backup*
*-ns -\\-no-summaries*
*-nu -\\-no-update*
*-r -\\-hed-version*
*-s -\\-save-formats*
*-t -\\-task-names*
*-v -\\-verbose*
*-w -\\-work-dir*
*-x -\\-exclude-dirs* | Restructure or summarize the event files. | -|*run_remodel_restore* | *data_dir*
*-n -\\-backup-name*
*-t -\\-task-names*
*-v -\\-verbose*
*-w -\\-work-dir*
| Restore a backup of event files. | +|*run_remodel_backup* | *data_dir*
*-bd -\\-backup-dir*
*-bn -\\-backup-name*
*-e -\\-extensions*
*-f -\\-file-suffix*
*-t -\\-task-names*
*-v -\\-verbose*
*-x -\\-exclude-dirs*| Create a backup event files. | +|*run_remodel* | *data_dir*
*model_path*
*-b -\\-bids-format*
*-bd -\\-backup-dir*
*-bn -\\-backup-name*
*-e -\\-extensions*
*-f -\\-file-suffix*
*-i -\\-individual-summaries*
*-j -\\-json-sidecar*
*-nb -\\-no-backup*
*-ns -\\-no-summaries*
*-nu -\\-no-update*
*-r -\\-hed-version*
*-s -\\-save-formats*
*-t -\\-task-names*
*-v -\\-verbose*
*-w -\\-work-dir*
*-x -\\-exclude-dirs* | Restructure or summarize the event files. | +|*run_remodel_restore* | *data_dir*
*-bd -\\-backup-dir*
*-bn -\\-backup-name*
*-t -\\-task-names*
*-v -\\-verbose*
| Restore a backup of event files. | ```` All the scripts have a required argument, which is the full path of the dataset root (*data_dir*). @@ -278,6 +278,13 @@ Users are free to use either form. `-b`, `--bids-format` > If this flag present, the dataset is in BIDS format with sidecars. Tabular files and their associated sidecars are located using BIDS naming. +`-bd`, `--backup-dir` +> The path to the directory holding the backups (default: `[data_root]/derivatives/remodel/backups`). +> Use the `-nb` option if you wish to omit the backup (in `run_remodel`). + +`-bn`, `--backup-name` +> The name of the backup used for the remodeling (default: `default_back`). + `-e`, `--extensions` > This option is followed by a list of file extension(s) of the data files to process. > The default is `.tsv`. Comma separated tabular files are not permitted. @@ -298,9 +305,6 @@ Users are free to use either form. > This option is followed by the full path of the JSON sidecar with HED annotations to be > applied during the processing of HED-related remodeling operations. -`-n`, `--backup-name` -> The name of the backup used for the remodeling (default: `default_back`). - `-nb`, `--no-backup` > If present, no backup is used. Rather operations are performed directly on the files. @@ -346,7 +350,7 @@ Users are free to use either form. > are printed to standard output. `-w`, `--work-dir` -> The path to the remodeling work root directory --both for backups and summaries (default: `[data_root]/derivatives/remodel`). +> The path to the remodeling work root directory --both for summaries (default: `[data_root]/derivatives/remodel`). > Use the `-nb` option if you wish to omit the backup (in `run_remodel`). `-x`, `--exclude-dirs` diff --git a/hedcode/jupyter_notebooks/remodeling/run_remodel.ipynb b/hedcode/jupyter_notebooks/remodeling/run_remodel.ipynb index e1eb3714..d02dc5f0 100644 --- a/hedcode/jupyter_notebooks/remodeling/run_remodel.ipynb +++ b/hedcode/jupyter_notebooks/remodeling/run_remodel.ipynb @@ -30,23 +30,84 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "outputs": [ { - "ename": "JSONDecodeError", - "evalue": "Expecting value: line 11 column 1 (char 335)", - "output_type": "error", - "traceback": [ - "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m", - "\u001B[1;31mJSONDecodeError\u001B[0m Traceback (most recent call last)", - "Cell \u001B[1;32mIn [2], line 12\u001B[0m\n\u001B[0;32m 9\u001B[0m os\u001B[38;5;241m.\u001B[39mmakedirs(output_dir, exist_ok\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m)\n\u001B[0;32m 10\u001B[0m arg_list \u001B[38;5;241m=\u001B[39m [data_root, model_path, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m-nb\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m-x\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mderivatives\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mstimuli\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124msourcedata\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mstimuli\u001B[39m\u001B[38;5;124m'\u001B[39m,\n\u001B[0;32m 11\u001B[0m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m-f\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mevents\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m-e\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m.tsv\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m-w\u001B[39m\u001B[38;5;124m'\u001B[39m, output_dir, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m-i\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mconsolidated\u001B[39m\u001B[38;5;124m'\u001B[39m]\n\u001B[1;32m---> 12\u001B[0m cli_remodel\u001B[38;5;241m.\u001B[39mmain(arg_list)\n", - "File \u001B[1;32mH:\\HEDExamples\\hed-examples\\venv\\lib\\site-packages\\hed\\tools\\remodeling\\cli\\run_remodel.py:158\u001B[0m, in \u001B[0;36mmain\u001B[1;34m(arg_list)\u001B[0m\n\u001B[0;32m 146\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mmain\u001B[39m(arg_list\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m):\n\u001B[0;32m 147\u001B[0m \u001B[38;5;124;03m\"\"\" The command-line program.\u001B[39;00m\n\u001B[0;32m 148\u001B[0m \n\u001B[0;32m 149\u001B[0m \u001B[38;5;124;03m Parameters:\u001B[39;00m\n\u001B[1;32m (...)\u001B[0m\n\u001B[0;32m 156\u001B[0m \n\u001B[0;32m 157\u001B[0m \u001B[38;5;124;03m \"\"\"\u001B[39;00m\n\u001B[1;32m--> 158\u001B[0m args, operations \u001B[38;5;241m=\u001B[39m \u001B[43mparse_arguments\u001B[49m\u001B[43m(\u001B[49m\u001B[43marg_list\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 159\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m os\u001B[38;5;241m.\u001B[39mpath\u001B[38;5;241m.\u001B[39misdir(args\u001B[38;5;241m.\u001B[39mdata_dir):\n\u001B[0;32m 160\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m HedFileError(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mDataDirectoryDoesNotExist\u001B[39m\u001B[38;5;124m\"\u001B[39m, \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mThe root data directory \u001B[39m\u001B[38;5;132;01m{\u001B[39;00margs\u001B[38;5;241m.\u001B[39mdata_dir\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m does not exist\u001B[39m\u001B[38;5;124m\"\u001B[39m, \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n", - "File \u001B[1;32mH:\\HEDExamples\\hed-examples\\venv\\lib\\site-packages\\hed\\tools\\remodeling\\cli\\run_remodel.py:83\u001B[0m, in \u001B[0;36mparse_arguments\u001B[1;34m(arg_list)\u001B[0m\n\u001B[0;32m 81\u001B[0m \u001B[38;5;28mprint\u001B[39m(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mData directory: \u001B[39m\u001B[38;5;132;01m{\u001B[39;00margs\u001B[38;5;241m.\u001B[39mdata_dir\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;130;01m\\n\u001B[39;00m\u001B[38;5;124mRemodel path: \u001B[39m\u001B[38;5;132;01m{\u001B[39;00margs\u001B[38;5;241m.\u001B[39mremodel_path\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m 82\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28mopen\u001B[39m(args\u001B[38;5;241m.\u001B[39mremodel_path, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mr\u001B[39m\u001B[38;5;124m'\u001B[39m) \u001B[38;5;28;01mas\u001B[39;00m fp:\n\u001B[1;32m---> 83\u001B[0m operations \u001B[38;5;241m=\u001B[39m \u001B[43mjson\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mload\u001B[49m\u001B[43m(\u001B[49m\u001B[43mfp\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 84\u001B[0m parsed_operations, errors \u001B[38;5;241m=\u001B[39m Dispatcher\u001B[38;5;241m.\u001B[39mparse_operations(operations)\n\u001B[0;32m 85\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m errors:\n", - "File \u001B[1;32mC:\\Program Files\\Python39\\lib\\json\\__init__.py:293\u001B[0m, in \u001B[0;36mload\u001B[1;34m(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001B[0m\n\u001B[0;32m 274\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mload\u001B[39m(fp, \u001B[38;5;241m*\u001B[39m, \u001B[38;5;28mcls\u001B[39m\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, object_hook\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, parse_float\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m,\n\u001B[0;32m 275\u001B[0m parse_int\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, parse_constant\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, object_pairs_hook\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkw):\n\u001B[0;32m 276\u001B[0m \u001B[38;5;124;03m\"\"\"Deserialize ``fp`` (a ``.read()``-supporting file-like object containing\u001B[39;00m\n\u001B[0;32m 277\u001B[0m \u001B[38;5;124;03m a JSON document) to a Python object.\u001B[39;00m\n\u001B[0;32m 278\u001B[0m \n\u001B[1;32m (...)\u001B[0m\n\u001B[0;32m 291\u001B[0m \u001B[38;5;124;03m kwarg; otherwise ``JSONDecoder`` is used.\u001B[39;00m\n\u001B[0;32m 292\u001B[0m \u001B[38;5;124;03m \"\"\"\u001B[39;00m\n\u001B[1;32m--> 293\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m loads(fp\u001B[38;5;241m.\u001B[39mread(),\n\u001B[0;32m 294\u001B[0m \u001B[38;5;28mcls\u001B[39m\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mcls\u001B[39m, object_hook\u001B[38;5;241m=\u001B[39mobject_hook,\n\u001B[0;32m 295\u001B[0m parse_float\u001B[38;5;241m=\u001B[39mparse_float, parse_int\u001B[38;5;241m=\u001B[39mparse_int,\n\u001B[0;32m 296\u001B[0m parse_constant\u001B[38;5;241m=\u001B[39mparse_constant, object_pairs_hook\u001B[38;5;241m=\u001B[39mobject_pairs_hook, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkw)\n", - "File \u001B[1;32mC:\\Program Files\\Python39\\lib\\json\\__init__.py:346\u001B[0m, in \u001B[0;36mloads\u001B[1;34m(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001B[0m\n\u001B[0;32m 341\u001B[0m s \u001B[38;5;241m=\u001B[39m s\u001B[38;5;241m.\u001B[39mdecode(detect_encoding(s), \u001B[38;5;124m'\u001B[39m\u001B[38;5;124msurrogatepass\u001B[39m\u001B[38;5;124m'\u001B[39m)\n\u001B[0;32m 343\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m (\u001B[38;5;28mcls\u001B[39m \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m \u001B[38;5;129;01mand\u001B[39;00m object_hook \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m \u001B[38;5;129;01mand\u001B[39;00m\n\u001B[0;32m 344\u001B[0m parse_int \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m \u001B[38;5;129;01mand\u001B[39;00m parse_float \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m \u001B[38;5;129;01mand\u001B[39;00m\n\u001B[0;32m 345\u001B[0m parse_constant \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m \u001B[38;5;129;01mand\u001B[39;00m object_pairs_hook \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m \u001B[38;5;129;01mand\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m kw):\n\u001B[1;32m--> 346\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[43m_default_decoder\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mdecode\u001B[49m\u001B[43m(\u001B[49m\u001B[43ms\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 347\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mcls\u001B[39m \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n\u001B[0;32m 348\u001B[0m \u001B[38;5;28mcls\u001B[39m \u001B[38;5;241m=\u001B[39m JSONDecoder\n", - "File \u001B[1;32mC:\\Program Files\\Python39\\lib\\json\\decoder.py:337\u001B[0m, in \u001B[0;36mJSONDecoder.decode\u001B[1;34m(self, s, _w)\u001B[0m\n\u001B[0;32m 332\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21mdecode\u001B[39m(\u001B[38;5;28mself\u001B[39m, s, _w\u001B[38;5;241m=\u001B[39mWHITESPACE\u001B[38;5;241m.\u001B[39mmatch):\n\u001B[0;32m 333\u001B[0m \u001B[38;5;124;03m\"\"\"Return the Python representation of ``s`` (a ``str`` instance\u001B[39;00m\n\u001B[0;32m 334\u001B[0m \u001B[38;5;124;03m containing a JSON document).\u001B[39;00m\n\u001B[0;32m 335\u001B[0m \n\u001B[0;32m 336\u001B[0m \u001B[38;5;124;03m \"\"\"\u001B[39;00m\n\u001B[1;32m--> 337\u001B[0m obj, end \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mraw_decode\u001B[49m\u001B[43m(\u001B[49m\u001B[43ms\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43midx\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43m_w\u001B[49m\u001B[43m(\u001B[49m\u001B[43ms\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m0\u001B[39;49m\u001B[43m)\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mend\u001B[49m\u001B[43m(\u001B[49m\u001B[43m)\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 338\u001B[0m end \u001B[38;5;241m=\u001B[39m _w(s, end)\u001B[38;5;241m.\u001B[39mend()\n\u001B[0;32m 339\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m end \u001B[38;5;241m!=\u001B[39m \u001B[38;5;28mlen\u001B[39m(s):\n", - "File \u001B[1;32mC:\\Program Files\\Python39\\lib\\json\\decoder.py:355\u001B[0m, in \u001B[0;36mJSONDecoder.raw_decode\u001B[1;34m(self, s, idx)\u001B[0m\n\u001B[0;32m 353\u001B[0m obj, end \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mscan_once(s, idx)\n\u001B[0;32m 354\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m err:\n\u001B[1;32m--> 355\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m JSONDecodeError(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mExpecting value\u001B[39m\u001B[38;5;124m\"\u001B[39m, s, err\u001B[38;5;241m.\u001B[39mvalue) \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;28mNone\u001B[39m\n\u001B[0;32m 356\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m obj, end\n", - "\u001B[1;31mJSONDecodeError\u001B[0m: Expecting value: line 11 column 1 (char 335)" + "name": "stdout", + "output_type": "stream", + "text": [ + "Data directory: \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\n", + "Model path: \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\summarize_validate_rmdl.json\n", + "Successfully parsed BIDS dataset with HED schema ['\"8.0.0\"']\n", + "Processing \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-01\\ses-01\\eeg\\sub-01_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-01\\ses-01\\eeg\\sub-01_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-01\\ses-01\\eeg\\sub-01_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-01\\ses-01\\eeg\\sub-01_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-02\\ses-01\\eeg\\sub-02_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-02\\ses-01\\eeg\\sub-02_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-02\\ses-01\\eeg\\sub-02_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-02\\ses-01\\eeg\\sub-02_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-03\\ses-01\\eeg\\sub-03_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-03\\ses-01\\eeg\\sub-03_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-03\\ses-01\\eeg\\sub-03_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-03\\ses-01\\eeg\\sub-03_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-04\\ses-01\\eeg\\sub-04_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-04\\ses-01\\eeg\\sub-04_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-04\\ses-01\\eeg\\sub-04_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-04\\ses-01\\eeg\\sub-04_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-05\\ses-01\\eeg\\sub-05_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-05\\ses-01\\eeg\\sub-05_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-05\\ses-01\\eeg\\sub-05_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-05\\ses-01\\eeg\\sub-05_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-06\\ses-01\\eeg\\sub-06_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-06\\ses-01\\eeg\\sub-06_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-06\\ses-01\\eeg\\sub-06_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-06\\ses-01\\eeg\\sub-06_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-07\\ses-01\\eeg\\sub-07_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-07\\ses-01\\eeg\\sub-07_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-07\\ses-01\\eeg\\sub-07_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-07\\ses-01\\eeg\\sub-07_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-08\\ses-01\\eeg\\sub-08_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-08\\ses-01\\eeg\\sub-08_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-08\\ses-01\\eeg\\sub-08_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-08\\ses-01\\eeg\\sub-08_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-09\\ses-01\\eeg\\sub-09_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-09\\ses-01\\eeg\\sub-09_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-09\\ses-01\\eeg\\sub-09_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-09\\ses-01\\eeg\\sub-09_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-10\\ses-01\\eeg\\sub-10_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-10\\ses-01\\eeg\\sub-10_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-10\\ses-01\\eeg\\sub-10_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-10\\ses-01\\eeg\\sub-10_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-11\\ses-01\\eeg\\sub-11_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-11\\ses-01\\eeg\\sub-11_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-11\\ses-01\\eeg\\sub-11_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-11\\ses-01\\eeg\\sub-11_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-12\\ses-01\\eeg\\sub-12_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-12\\ses-01\\eeg\\sub-12_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-12\\ses-01\\eeg\\sub-12_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-12\\ses-01\\eeg\\sub-12_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-13\\ses-01\\eeg\\sub-13_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-13\\ses-01\\eeg\\sub-13_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-13\\ses-01\\eeg\\sub-13_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-13\\ses-01\\eeg\\sub-13_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-14\\ses-01\\eeg\\sub-14_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-14\\ses-01\\eeg\\sub-14_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-14\\ses-01\\eeg\\sub-14_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-14\\ses-01\\eeg\\sub-14_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-15\\ses-01\\eeg\\sub-15_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-15\\ses-01\\eeg\\sub-15_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-15\\ses-01\\eeg\\sub-15_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-15\\ses-01\\eeg\\sub-15_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-16\\ses-01\\eeg\\sub-16_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-16\\ses-01\\eeg\\sub-16_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-16\\ses-01\\eeg\\sub-16_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-16\\ses-01\\eeg\\sub-16_ses-01_task-DriveRandomSound_run-2_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-17\\ses-01\\eeg\\sub-17_ses-01_task-DriveRandomSound_run-1_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-17\\ses-01\\eeg\\sub-17_ses-01_task-DriveRandomSound_run-1_events.tsv...\n", + "Tabular file \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-17\\ses-01\\eeg\\sub-17_ses-01_task-DriveRandomSound_run-2_events.tsv sidecar \n", + "Reading \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-17\\ses-01\\eeg\\sub-17_ses-01_task-DriveRandomSound_run-2_events.tsv...\n" ] } ], @@ -55,13 +116,10 @@ "import shutil\n", "import hed.tools.remodeling.cli.run_remodel as cli_remodel\n", "\n", - "data_root = os.path.realpath('G:/ds002338_openNeuro')\n", - "model_path = os.path.realpath('T:/summaryTests/summarize_events_rmdl.json')\n", - "output_dir = './temp'\n", - "output_dir = os.path.realpath(output_dir)\n", - "os.makedirs(output_dir, exist_ok=True)\n", - "arg_list = [data_root, model_path, '-nb', '-x', 'derivatives', 'stimuli', 'sourcedata', 'stimuli',\n", - " '-f', 'events', '-e', '.tsv', '-w', output_dir, '-i', 'consolidated']\n", + "data_root = 't:/summaryTests/ds004105-download'\n", + "model_path = os.path.realpath(os.path.join(data_root, 'derivatives/remodel/summarize_validate_rmdl.json'))\n", + "arg_list = [data_root, model_path, '-b', '-nb', '-x', 'derivatives', 'stimuli', 'sourcedata', 'code',\n", + " '-f', 'events', '-e', '.tsv', '-i', 'consolidated', '-v']\n", "cli_remodel.main(arg_list)\n" ], "metadata": { @@ -70,18 +128,22 @@ "name": "#%% This removes all summaries from eeg_ds003645s_hed_remodel and then reruns.\n" }, "ExecuteTime": { - "end_time": "2023-08-29T19:55:07.528022400Z", - "start_time": "2023-08-29T19:55:05.774129200Z" + "end_time": "2023-10-22T21:36:00.919686Z", + "start_time": "2023-10-22T21:34:56.555799500Z" } } }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "outputs": [], "source": [], "metadata": { - "collapsed": false + "collapsed": false, + "ExecuteTime": { + "end_time": "2023-10-22T21:36:00.937688400Z", + "start_time": "2023-10-22T21:36:00.921685100Z" + } } } ], diff --git a/hedcode/jupyter_notebooks/remodeling/run_remodel_backup.ipynb b/hedcode/jupyter_notebooks/remodeling/run_remodel_backup.ipynb index 50d1ff41..94acca26 100644 --- a/hedcode/jupyter_notebooks/remodeling/run_remodel_backup.ipynb +++ b/hedcode/jupyter_notebooks/remodeling/run_remodel_backup.ipynb @@ -2,38 +2,70 @@ "cells": [ { "cell_type": "markdown", - "metadata": { - "collapsed": true, - "pycharm": { - "name": "#%% md\n" - } - }, "source": [ "# Backup the event files in a dataset\n", "\n", "This notebook calls `run_remodel_backup(arglist)` with a list of parameters from the following table\n", "to back up the events in a dataset.\n", "\n", - "| parameter | default | dest | other | meaning |\n", - "| --------- | ------- | ---- | ----- | ------- |\n", - "| data_dir | | data_dir | | Full path of dataset root directory. |,\n", - "| -n, --backup_name | default_back | backup_name | | Name of the default backup for remodeling. |\n", + "| parameter | default | dest | other | meaning |\n", + "|--------------------|------------------------------------------|-------------| ----- | ------- |\n", + "| data_dir | | data_dir | | Full path of dataset root directory. |\n", + "| -bd, --backup_dir | `[data_root]/derivatives/remodel/backups` | backup_dir | | Name of the default backup for remodeling. |\n", + "| -bn, --backup_name | `default_back` | backup_name | | Name of the default backup for remodeling. |\n", + "| -e, --extensions | ['.tsv'] | extensions | nargs=* |File extensions to allow in locating files.
A * indicates all files allowed. |\n", + "| -f, --file-suffix | ['events'] | file_suffix | nargs=* | Filename suffix of files to be backed up.
A * indicates all files allowed. |\n", "| -t, --task-names | [] |task_names | nargs=* | The name of the task. |\n", - "| -x, --exclude-dirs | [] | exclude_dirs | nargs=* | Directories names to exclude from search for files.
If omitted, no directories except the backup directory will be excluded.
Note data_dir/remodel/backup will always be excluded. |\n", - "| -f, --file-suffix | ['events'] | file_suffix | nargs=* | Filename suffix of files to be backed up.
A * indicates all files allowed. |\n", - "| -e, --extensions | ['.tsv'] | extensions | nargs=* |File extensions to allow in locating files.
A * indicates all files allowed. |\n", - "| -v, --verbose | | verbose |action=store_true | If present, output informative messages as computation progresses. |" - ] + "| -v, --verbose | | verbose |action=store_true | If present, output informative messages as computation progresses. | \n", + "| -x, --exclude-dirs | [] | exclude_dirs | nargs=* | Directories names to exclude from search for files.
If omitted, no directories except the backup directory will be excluded.
Note data_dir/remodel/backup will always be excluded. |" + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "A backup test_backup has been created.\n" + "Creating backup test_backup\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-01\\ses-01\\eeg\\sub-01_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-01\\ses-01\\eeg\\sub-01_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-01\\ses-01\\eeg\\sub-01_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-01\\ses-01\\eeg\\sub-01_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-02\\ses-01\\eeg\\sub-02_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-02\\ses-01\\eeg\\sub-02_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-02\\ses-01\\eeg\\sub-02_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-02\\ses-01\\eeg\\sub-02_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-03\\ses-01\\eeg\\sub-03_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-03\\ses-01\\eeg\\sub-03_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-03\\ses-01\\eeg\\sub-03_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-03\\ses-01\\eeg\\sub-03_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-04\\ses-01\\eeg\\sub-04_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-04\\ses-01\\eeg\\sub-04_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-04\\ses-01\\eeg\\sub-04_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-04\\ses-01\\eeg\\sub-04_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-05\\ses-01\\eeg\\sub-05_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-05\\ses-01\\eeg\\sub-05_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-05\\ses-01\\eeg\\sub-05_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-05\\ses-01\\eeg\\sub-05_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-06\\ses-01\\eeg\\sub-06_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-06\\ses-01\\eeg\\sub-06_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-06\\ses-01\\eeg\\sub-06_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-06\\ses-01\\eeg\\sub-06_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-07\\ses-01\\eeg\\sub-07_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-07\\ses-01\\eeg\\sub-07_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-07\\ses-01\\eeg\\sub-07_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-07\\ses-01\\eeg\\sub-07_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-08\\ses-01\\eeg\\sub-08_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-08\\ses-01\\eeg\\sub-08_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-08\\ses-01\\eeg\\sub-08_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-08\\ses-01\\eeg\\sub-08_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-09\\ses-01\\eeg\\sub-09_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-09\\ses-01\\eeg\\sub-09_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-09\\ses-01\\eeg\\sub-09_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-09\\ses-01\\eeg\\sub-09_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-10\\ses-01\\eeg\\sub-10_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-10\\ses-01\\eeg\\sub-10_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-10\\ses-01\\eeg\\sub-10_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-10\\ses-01\\eeg\\sub-10_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-11\\ses-01\\eeg\\sub-11_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-11\\ses-01\\eeg\\sub-11_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-11\\ses-01\\eeg\\sub-11_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-11\\ses-01\\eeg\\sub-11_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-12\\ses-01\\eeg\\sub-12_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-12\\ses-01\\eeg\\sub-12_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-12\\ses-01\\eeg\\sub-12_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-12\\ses-01\\eeg\\sub-12_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-13\\ses-01\\eeg\\sub-13_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-13\\ses-01\\eeg\\sub-13_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-13\\ses-01\\eeg\\sub-13_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-13\\ses-01\\eeg\\sub-13_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-14\\ses-01\\eeg\\sub-14_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-14\\ses-01\\eeg\\sub-14_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-14\\ses-01\\eeg\\sub-14_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-14\\ses-01\\eeg\\sub-14_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-15\\ses-01\\eeg\\sub-15_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-15\\ses-01\\eeg\\sub-15_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-15\\ses-01\\eeg\\sub-15_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-15\\ses-01\\eeg\\sub-15_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-16\\ses-01\\eeg\\sub-16_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-16\\ses-01\\eeg\\sub-16_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-16\\ses-01\\eeg\\sub-16_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-16\\ses-01\\eeg\\sub-16_ses-01_task-DriveRandomSound_run-2_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-17\\ses-01\\eeg\\sub-17_ses-01_task-DriveRandomSound_run-1_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-17\\ses-01\\eeg\\sub-17_ses-01_task-DriveRandomSound_run-1_events.tsv\n", + "Copying \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\sub-17\\ses-01\\eeg\\sub-17_ses-01_task-DriveRandomSound_run-2_events.tsv to \\\\192.168.0.179\\NASdata4\\summaryTests\\ds004105-download\\derivatives\\remodel\\backups\\test_backup\\backup_root\\sub-17\\ses-01\\eeg\\sub-17_ses-01_task-DriveRandomSound_run-2_events.tsv\n" ] } ], @@ -41,24 +73,21 @@ "import os\n", "import hed.tools.remodeling.cli.run_remodel_backup as cli_backup\n", "\n", - "data_root = os.path.realpath('../../../datasets/eeg_ds003645s_hed_remodel')\n", + "#data_root = os.path.realpath('../../../datasets/eeg_ds003645s_hed_remodel')\n", + "data_root = 't:/summaryTests/ds004105-download'\n", "backup_name = 'test_backup'\n", - "backup_dir = os.path.realpath(os.path.join(data_root, 'derivatives/remodel/backups', 'test_backup'))\n", - "if os.path.isdir(backup_dir):\n", - " print(f\"Warning a backup called {backup_name} already exists so cannot make new one.\")\n", - "else:\n", - " arg_list = [data_root, '-n', 'test_backup', '-x', 'derivatives', 'stimuli',\n", - " '-f', 'events', '-e', '.tsv']\n", - " cli_backup.main(arg_list)\n", - " if os.path.isdir(backup_dir):\n", - " print(f\"A backup {backup_name} has been created.\")\n", - " else:\n", - " print(f\"Backup {backup_name} has failed to be created.\")\n" + "arg_list = [data_root, '-bn', backup_name, '-x', 'derivatives', 'stimuli', 'code', 'sourcedata'\n", + " '-f', 'events', '-e', '.tsv', '-v']\n", + "cli_backup.main(arg_list)\n" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" + }, + "ExecuteTime": { + "end_time": "2023-10-22T21:27:19.165151200Z", + "start_time": "2023-10-22T21:27:17.679498700Z" } } } @@ -84,4 +113,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} diff --git a/hedcode/matlab_scripts/data_cleaning/runEeglabImportEvents.m b/hedcode/matlab_scripts/data_cleaning/runEeglabImportEvents.m index 2ab6c892..e8b164d0 100644 --- a/hedcode/matlab_scripts/data_cleaning/runEeglabImportEvents.m +++ b/hedcode/matlab_scripts/data_cleaning/runEeglabImportEvents.m @@ -1,88 +1,89 @@ %% This imports the _events.tsv into the corresponding EEG.set file %% Set up the specifics for your dataset - -rootPath = '/XXX/SternbergWorkingPhaseTwo'; -setname = ''; -log_name = 'sternberg_12_import_events_log.txt'; -renameColumns = {'event_type', 'type'; 'onset', 'latency'}; - -% rootPath = 'G:/AttentionShift/AttentionShiftWorkingPhaseTwo'; -% setname = 'Auditory Visual Attention Shift'; -% log_name = 'attention_shift_18_import_events_log.txt'; - -% rootPath = 's:/bcit/AdvancedGuardDutyWorkingPhaseTwo'; -% setname = 'BCIT Advanced Guard Duty'; -% log_name = 'bcit_advanced_guard_duty_10_import_events_log.txt'; +filename = 'T:SummaryTests/ds004105-download/sub-01/ses-01/eeg/sub-01_ses-01_task-DriveRandomSound_run-1_events.tsv'; +eventstruct = importevent( filename, [], 1024, 'key1', 'value1', ...); +% rootPath = '/XXX/SternbergWorkingPhaseTwo'; +% setname = ''; +% log_name = 'sternberg_12_import_events_log.txt'; +% renameColumns = {'event_type', 'type'; 'onset', 'latency'}; % -% rootPath = 's:/bcit/AuditoryCueingWorkingPhaseTwo'; -% setname = 'BCIT Auditory Cueing'; -% log_name = 'bcit_auditory_cueing_10_import_events_log.txt'; - -% rootPath = 's:/bcit/BaselineDrivingWorkingPhaseTwo'; -% setname = 'BCIT Baseline Driving'; -% log_name = 'bcit_baseline_driving_10_import_events_log.txt'; - -% rootPath = 's:/bcit/BasicGuardDutyWorkingPhaseTwo'; -% setname = 'BCIT Basic Guard Duty'; -% log_name = 'bcit_basic_guard_duty_10_import_events_log.txt'; - -% rootPath = 's:/bcit/CalibrationDrivingWorkingPhaseTwo'; -% setname = 'BCIT Calibration Driving'; -% log_name = 'bcit_calibration_driving_10_import_events_log.txt'; - -% rootPath = 's:/bcit/MindWanderingWorkingPhaseTwo'; -% setname = 'BCIT Mind Wandering'; -% log_name = 'bcit_mind_wandering_10_import_events_log.txt'; - -% rootPath = 's:/bcit/SpeedControlWorkingPhaseTwo'; -% setname = 'BCIT Speed Control'; -% log_name = 'bcit_speed_control_10_import_events_log.txt'; - -% rootPath = 's:/bcit/TrafficComplexityWorkingPhaseTwo'; -% setname = 'BCIT Traffic Complexity'; -% log_name = 'bcit_traffic_complexity_10_import_events_log.txt'; - -excludeDirs = {'sourcedata', 'code', 'stimuli'}; -namePrefix = ''; -nameSuffix = '_eeg'; -extensions = {'.set'}; - -% Designate the columns that are numeric (rest are char) -columnTypes = {'onset', 'double'; 'duration', 'double'; 'sample', 'int32'}; - -convertLatency = true; - -%% Open the log -fid = fopen([rootPath filesep 'code/curation_logs', filesep log_name], 'w'); -fprintf(fid, 'Log of runEeglabEventsImport.m on %s\n', datetime('now')); - -%% Generate json file. -fileList = getFileList(rootPath, namePrefix, nameSuffix, ... - extensions, excludeDirs); -for k = 1:length(fileList) - EEG = pop_loadset(fileList{k}); - [pathName, basename, ext] = fileparts(fileList{k}); - fprintf(fid, '%s:\n', basename); - eventsFile = [pathName filesep basename(1:(end-3)) 'events.tsv']; - eventTable = getEventTable(eventsFile, columnTypes, renameColumns); - fprintf(fid, '\tCreate a table from the events file\n'); - if convertLatency - eventTable.('latency') = eventTable.('latency')*EEG.srate + 1; - fprintf(fid, '\tConvert the latency column to samples\n'); - end - fprintf('%s: EEG.event has %d events and BIDS event file has %d events\n', ... - basename, length(EEG.event), size(eventTable,1)); - EEG.urevent = table2struct(eventTable)'; - fprintf(fid, '\tSet the EEG.urevent\n'); - eventTable.('urevent') = transpose(1:size(eventTable)); - EEG.event = table2struct(eventTable)'; - fprintf(fid, '\tSet the EEG.event\n'); - if ~isempty(setname) - EEG.setname = [setname basename]; - fprintf(fid, '\tSet the EEG.setname\n'); - end - fprintf(fid, '\tResave the EEG.set file\n'); - EEG = pop_saveset(EEG, 'savemode', 'resave', 'version', '7.3'); -end -fclose(fid); \ No newline at end of file +% % rootPath = 'G:/AttentionShift/AttentionShiftWorkingPhaseTwo'; +% % setname = 'Auditory Visual Attention Shift'; +% % log_name = 'attention_shift_18_import_events_log.txt'; +% +% % rootPath = 's:/bcit/AdvancedGuardDutyWorkingPhaseTwo'; +% % setname = 'BCIT Advanced Guard Duty'; +% % log_name = 'bcit_advanced_guard_duty_10_import_events_log.txt'; +% % +% % rootPath = 's:/bcit/AuditoryCueingWorkingPhaseTwo'; +% % setname = 'BCIT Auditory Cueing'; +% % log_name = 'bcit_auditory_cueing_10_import_events_log.txt'; +% +% % rootPath = 's:/bcit/BaselineDrivingWorkingPhaseTwo'; +% % setname = 'BCIT Baseline Driving'; +% % log_name = 'bcit_baseline_driving_10_import_events_log.txt'; +% +% % rootPath = 's:/bcit/BasicGuardDutyWorkingPhaseTwo'; +% % setname = 'BCIT Basic Guard Duty'; +% % log_name = 'bcit_basic_guard_duty_10_import_events_log.txt'; +% +% % rootPath = 's:/bcit/CalibrationDrivingWorkingPhaseTwo'; +% % setname = 'BCIT Calibration Driving'; +% % log_name = 'bcit_calibration_driving_10_import_events_log.txt'; +% +% % rootPath = 's:/bcit/MindWanderingWorkingPhaseTwo'; +% % setname = 'BCIT Mind Wandering'; +% % log_name = 'bcit_mind_wandering_10_import_events_log.txt'; +% +% % rootPath = 's:/bcit/SpeedControlWorkingPhaseTwo'; +% % setname = 'BCIT Speed Control'; +% % log_name = 'bcit_speed_control_10_import_events_log.txt'; +% +% % rootPath = 's:/bcit/TrafficComplexityWorkingPhaseTwo'; +% % setname = 'BCIT Traffic Complexity'; +% % log_name = 'bcit_traffic_complexity_10_import_events_log.txt'; +% +% excludeDirs = {'sourcedata', 'code', 'stimuli', 'derivatives'}; +% namePrefix = ''; +% nameSuffix = '_eeg'; +% extensions = {'.set'}; +% +% % Designate the columns that are numeric (rest are char) +% columnTypes = {'onset', 'double'; 'duration', 'double'; 'sample', 'int32'}; +% +% convertLatency = true; +% +% %% Open the log +% fid = fopen([rootPath filesep 'code/curation_logs', filesep log_name], 'w'); +% fprintf(fid, 'Log of runEeglabEventsImport.m on %s\n', datetime('now')); +% +% %% Generate json file. +% fileList = getFileList(rootPath, namePrefix, nameSuffix, ... +% extensions, excludeDirs); +% for k = 1:length(fileList) +% EEG = pop_loadset(fileList{k}); +% [pathName, basename, ext] = fileparts(fileList{k}); +% fprintf(fid, '%s:\n', basename); +% eventsFile = [pathName filesep basename(1:(end-3)) 'events.tsv']; +% eventTable = getEventTable(eventsFile, columnTypes, renameColumns); +% fprintf(fid, '\tCreate a table from the events file\n'); +% if convertLatency +% eventTable.('latency') = eventTable.('latency')*EEG.srate + 1; +% fprintf(fid, '\tConvert the latency column to samples\n'); +% end +% fprintf('%s: EEG.event has %d events and BIDS event file has %d events\n', ... +% basename, length(EEG.event), size(eventTable,1)); +% EEG.urevent = table2struct(eventTable)'; +% fprintf(fid, '\tSet the EEG.urevent\n'); +% eventTable.('urevent') = transpose(1:size(eventTable)); +% EEG.event = table2struct(eventTable)'; +% fprintf(fid, '\tSet the EEG.event\n'); +% if ~isempty(setname) +% EEG.setname = [setname basename]; +% fprintf(fid, '\tSet the EEG.setname\n'); +% end +% fprintf(fid, '\tResave the EEG.set file\n'); +% EEG = pop_saveset(EEG, 'savemode', 'resave', 'version', '7.3'); +% end +% fclose(fid); \ No newline at end of file diff --git a/hedcode/matlab_scripts/data_cleaning/runEeglabImportEventsOld.m b/hedcode/matlab_scripts/data_cleaning/runEeglabImportEventsOld.m new file mode 100644 index 00000000..4b839b37 --- /dev/null +++ b/hedcode/matlab_scripts/data_cleaning/runEeglabImportEventsOld.m @@ -0,0 +1,88 @@ +%% This imports the _events.tsv into the corresponding EEG.set file + +%% Set up the specifics for your dataset + +rootPath = '/XXX/SternbergWorkingPhaseTwo'; +setname = ''; +log_name = 'sternberg_12_import_events_log.txt'; +renameColumns = {'event_type', 'type'; 'onset', 'latency'}; + +% rootPath = 'G:/AttentionShift/AttentionShiftWorkingPhaseTwo'; +% setname = 'Auditory Visual Attention Shift'; +% log_name = 'attention_shift_18_import_events_log.txt'; + +% rootPath = 's:/bcit/AdvancedGuardDutyWorkingPhaseTwo'; +% setname = 'BCIT Advanced Guard Duty'; +% log_name = 'bcit_advanced_guard_duty_10_import_events_log.txt'; +% +% rootPath = 's:/bcit/AuditoryCueingWorkingPhaseTwo'; +% setname = 'BCIT Auditory Cueing'; +% log_name = 'bcit_auditory_cueing_10_import_events_log.txt'; + +% rootPath = 's:/bcit/BaselineDrivingWorkingPhaseTwo'; +% setname = 'BCIT Baseline Driving'; +% log_name = 'bcit_baseline_driving_10_import_events_log.txt'; + +% rootPath = 's:/bcit/BasicGuardDutyWorkingPhaseTwo'; +% setname = 'BCIT Basic Guard Duty'; +% log_name = 'bcit_basic_guard_duty_10_import_events_log.txt'; + +% rootPath = 's:/bcit/CalibrationDrivingWorkingPhaseTwo'; +% setname = 'BCIT Calibration Driving'; +% log_name = 'bcit_calibration_driving_10_import_events_log.txt'; + +% rootPath = 's:/bcit/MindWanderingWorkingPhaseTwo'; +% setname = 'BCIT Mind Wandering'; +% log_name = 'bcit_mind_wandering_10_import_events_log.txt'; + +% rootPath = 's:/bcit/SpeedControlWorkingPhaseTwo'; +% setname = 'BCIT Speed Control'; +% log_name = 'bcit_speed_control_10_import_events_log.txt'; + +% rootPath = 's:/bcit/TrafficComplexityWorkingPhaseTwo'; +% setname = 'BCIT Traffic Complexity'; +% log_name = 'bcit_traffic_complexity_10_import_events_log.txt'; + +excludeDirs = {'sourcedata', 'code', 'stimuli', 'derivatives'}; +namePrefix = ''; +nameSuffix = '_eeg'; +extensions = {'.set'}; + +% Designate the columns that are numeric (rest are char) +columnTypes = {'onset', 'double'; 'duration', 'double'; 'sample', 'int32'}; + +convertLatency = true; + +%% Open the log +fid = fopen([rootPath filesep 'code/curation_logs', filesep log_name], 'w'); +fprintf(fid, 'Log of runEeglabEventsImport.m on %s\n', datetime('now')); + +%% Generate json file. +fileList = getFileList(rootPath, namePrefix, nameSuffix, ... + extensions, excludeDirs); +for k = 1:length(fileList) + EEG = pop_loadset(fileList{k}); + [pathName, basename, ext] = fileparts(fileList{k}); + fprintf(fid, '%s:\n', basename); + eventsFile = [pathName filesep basename(1:(end-3)) 'events.tsv']; + eventTable = getEventTable(eventsFile, columnTypes, renameColumns); + fprintf(fid, '\tCreate a table from the events file\n'); + if convertLatency + eventTable.('latency') = eventTable.('latency')*EEG.srate + 1; + fprintf(fid, '\tConvert the latency column to samples\n'); + end + fprintf('%s: EEG.event has %d events and BIDS event file has %d events\n', ... + basename, length(EEG.event), size(eventTable,1)); + EEG.urevent = table2struct(eventTable)'; + fprintf(fid, '\tSet the EEG.urevent\n'); + eventTable.('urevent') = transpose(1:size(eventTable)); + EEG.event = table2struct(eventTable)'; + fprintf(fid, '\tSet the EEG.event\n'); + if ~isempty(setname) + EEG.setname = [setname basename]; + fprintf(fid, '\tSet the EEG.setname\n'); + end + fprintf(fid, '\tResave the EEG.set file\n'); + EEG = pop_saveset(EEG, 'savemode', 'resave', 'version', '7.3'); +end +fclose(fid); \ No newline at end of file diff --git a/hedcode/matlab_scripts/web_services/runAllTests.m b/hedcode/matlab_scripts/web_services/runAllTests.m index 7f437e50..6e279fd0 100644 --- a/hedcode/matlab_scripts/web_services/runAllTests.m +++ b/hedcode/matlab_scripts/web_services/runAllTests.m @@ -1,6 +1,6 @@ dochost = 'https://hedtools.org/hed'; %host = 'https://hedtools.org/hed_dev'; -%host = 'http://127.0.0.1:5000'; +host = 'http://127.0.0.1:5000'; errorMap = containers.Map('KeyType', 'char', 'ValueType', 'any'); diff --git a/hedcode/matlab_scripts/web_services/runTest.m b/hedcode/matlab_scripts/web_services/runTest.m index c5582843..6765f89c 100644 --- a/hedcode/matlab_scripts/web_services/runTest.m +++ b/hedcode/matlab_scripts/web_services/runTest.m @@ -4,4 +4,4 @@ %host = 'https://hedtools.ucsd.edu/hed_dev'; %errors = testLibraryServices(host); %errors = testSpreadsheetServices(host); -errors = testStringServices(host); \ No newline at end of file +errors = testEventSearchServices(host); \ No newline at end of file diff --git a/hedcode/matlab_scripts/web_services/testEventSearchServices.m b/hedcode/matlab_scripts/web_services/testEventSearchServices.m index 7231e3bb..6f71911c 100644 --- a/hedcode/matlab_scripts/web_services/testEventSearchServices.m +++ b/hedcode/matlab_scripts/web_services/testEventSearchServices.m @@ -25,19 +25,19 @@ errors{end + 1} = 'Example 1 failed execute the search.'; end -%% Example 2: Search an events file for HED -request2 = struct('service', 'events_search', ... - 'schema_version', '8.0.0', ... - 'sidecar_string', data.jsonText, ... - 'events_string', data.eventsText, ... - 'columns_included', '', ... - 'query', '[[Intended-effect, Cue]]'); -request2.columns_included = {'onset'}; -response2 = webwrite(servicesUrl, request2, options); -response2 = jsondecode(response2); -outputReport(response2, 'Example 2 Querying an events file with extra columns'); -if ~isempty(response2.error_type) || ... - ~strcmpi(response2.results.msg_category, 'success') - errors{end + 1} = 'Example 2 failed execute the search.'; -end +% %% Example 2: Search an events file for HED +% request2 = struct('service', 'events_search', ... +% 'schema_version', '8.0.0', ... +% 'sidecar_string', data.jsonText, ... +% 'events_string', data.eventsText, ... +% 'columns_included', '', ... +% 'query', '[[Intended-effect, Cue]]'); +% request2.columns_included = {'onset'}; +% response2 = webwrite(servicesUrl, request2, options); +% response2 = jsondecode(response2); +% outputReport(response2, 'Example 2 Querying an events file with extra columns'); +% if ~isempty(response2.error_type) || ... +% ~strcmpi(response2.results.msg_category, 'success') +% errors{end + 1} = 'Example 2 failed execute the search.'; +% end