Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nbeliy committed Mar 18, 2024
0 parents commit 379fd5d
Show file tree
Hide file tree
Showing 5 changed files with 896 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.*
320 changes: 320 additions & 0 deletions notebook/bidsification_dev.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "ae1c3804-a043-4c9a-8cc7-0fdf5ef1452a",
"metadata": {},
"source": [
"# Development bidsification\n",
"\n",
"To be run on **test dataset** to configure and test bidsmap and plugins.\n",
"\n",
" - [Dataset path configuration](./configuration.ipynb): to define working paths\n",
" - [Production version](./bidsification_prod.ipynb): to use when bidsification need to be adjusted\n",
" - [Instalation notebook](installation.ipynb): if bidsme and other packages must be installed/updated"
]
},
{
"cell_type": "markdown",
"id": "fcf7d215-3235-4175-934f-a9d4dd0e2d2d",
"metadata": {},
"source": [
"# Initialisation"
]
},
{
"cell_type": "markdown",
"id": "65a00b8b-08cd-446c-bff7-a24f3700e72e",
"metadata": {},
"source": [
"To run once, after launching notebook or restarting kernel to initialize bidsme and setup paths\n",
"\n",
"> Verify the version of `bidsme` and import errors."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3350aac-411a-44bb-bcce-4bfef5f34b04",
"metadata": {},
"outputs": [],
"source": [
"import shutil\n",
"import bidsme\n",
"\n",
"bidsme.init()"
]
},
{
"cell_type": "markdown",
"id": "560dd018-3bce-4072-98b4-7e26a448ed9f",
"metadata": {},
"source": [
"Loading pre-defined paths from [configuration](./configuration.ipynb) notebook.\n",
" > **AssertionError** there will indicate badly defined paths. Fix them before going further!"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "909fedcb-3e62-4d13-86cb-36e51d764b70",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"%run \"./configuration.ipynb\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4ee14de1-2ab9-4b34-8167-4e1b0041a024",
"metadata": {},
"outputs": [],
"source": [
"source, prepared, bidsified = generate_paths(production=False)"
]
},
{
"cell_type": "markdown",
"id": "0b211814-f921-4397-93a3-9d119cd0edd1",
"metadata": {},
"source": [
"Insure that you are working on **Test** dataset (`production=False`)."
]
},
{
"cell_type": "markdown",
"id": "771b2174-f341-4fa4-bdc9-10483d49bbd0",
"metadata": {},
"source": [
"# Preparation"
]
},
{
"cell_type": "markdown",
"id": "cae30763-21af-4326-9d1a-3b8933a9e02a",
"metadata": {},
"source": [
"To run on test dataset when reconfiguration of preparation step is needed\n",
"\n",
" - [Preparation plugin file](../resources/plugins/prepare_plugin.py)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0fd1ef1f-da98-4e31-8d50-1212c999b1be",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"# Online help for preparation\n",
"?bidsme.prepare"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a5f5fa3-5bd8-4a0b-9819-fb44d02a7698",
"metadata": {},
"outputs": [],
"source": [
"# Cleanup prepared directory if needed\n",
"for f in os.listdir(prepared):\n",
" f = os.path.join(prepared, f)\n",
" if os.path.isdir(f):\n",
" shutil.rmtree(f)\n",
" else:\n",
" os.remove(f)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5b9cb6c7-1c2a-46b3-8b9b-faa7ca93a502",
"metadata": {},
"outputs": [],
"source": [
"# To manually set list of subjects to run with bidisified name, for ex.\n",
"# FCAVC012 becomes sub-AVC012\n",
"# If list is empty, preparation will run on all aviable subjects\n",
"participants = [\"sub-SCD001\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "25ae0658-0c30-4ec3-8120-8d8beb038279",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"bidsme.prepare(source, prepared,\n",
" data_dirs={\"MRI/s*/nii\": \"MRI\", \"VIZ/e*/\": \"PET\", \"UCB/e*/\": \"PET\"},\n",
" ses_no_dir=True,\n",
" plugin_file=prepare_plugin,\n",
" part_template=part_template,\n",
" sub_skip_tsv=True, sub_list=participants,\n",
" dry_run=False)"
]
},
{
"cell_type": "markdown",
"id": "f0ac2438-0beb-4264-a51d-e94b112233f1",
"metadata": {
"tags": []
},
"source": [
"# Map preparation"
]
},
{
"cell_type": "markdown",
"id": "f6d79bcf-97af-426c-b127-6d13f467ba37",
"metadata": {
"tags": []
},
"source": [
"> To run on test dataset when bidsmap must be created/adjusted\n",
"\n",
" - [Bidsification plugin file](../resources/plugins/bidsify_plugin.py)\n",
" - [Bidsmap file](../resources/map/bidsmap.yaml)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ee7f2db6-7b0f-414b-bb46-928b6a19d368",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"# Online help for creation of bidsmal\n",
"?bidsme.mapper"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5bbd05bf-7385-48c4-b6b2-f50d18ee5dff",
"metadata": {},
"outputs": [],
"source": [
"# To manually set list of subjects to run, put here one or two subjects with new protocol\n",
"participants = [\"sub-AVC012\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1f7d1f17-e354-49a9-9861-7d70d09ff038",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"bidsme.mapper(prepared, bidsified,\n",
" plugin_file=bidsify_plugin,\n",
" bidsmapfile=bidsmap,\n",
" sub_list=participants\n",
" )"
]
},
{
"cell_type": "markdown",
"id": "aad48cca-0ffa-490d-977e-71f7439fdc94",
"metadata": {},
"source": [
"# Bidsification"
]
},
{
"cell_type": "markdown",
"id": "e40d6123-0219-4648-9339-a3b2f31329ca",
"metadata": {},
"source": [
"> To run on test dataset when reconfiguration of bidsification is needed\n",
"\n",
" - [Bidsification plugin file](../plugins/bidsify_plugin.py)\n",
" - [Bidsmap file](../maps/bidsmap.yaml)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b40a2b2a-f9d9-4585-8d2f-53f39db9d88b",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"# Online help for bidsification\n",
"?bidsme.bidsify"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cd9c8801-d5d3-4042-a7fb-d8d2b9ce96f3",
"metadata": {},
"outputs": [],
"source": [
"# Cleanup bidsified directory if needed\n",
"for f in os.listdir(bidsified):\n",
" f = os.path.join(bidsified, f)\n",
" if os.path.isdir(f):\n",
" shutil.rmtree(f)\n",
" else:\n",
" os.remove(f)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9fe05cd3-c52c-4314-8276-2acadfa3b9a0",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"bidsme.bidsify(prepared, bidsified,\n",
" plugin_file=bidsify_plugin,\n",
" bidsmapfile=bidsmap,\n",
" sub_skip_tsv=True,\n",
" dry_run=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "bidsme (Python 3.10.13)",
"language": "python",
"name": "bidsme"
},
"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.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 379fd5d

Please sign in to comment.