Skip to content

Commit

Permalink
fixed bug if pixel inflation does not have consecutive start, middle …
Browse files Browse the repository at this point in the history
…and end.
  • Loading branch information
JulietteFrancovich committed Aug 28, 2024
1 parent f6e13d8 commit 36ddb7a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 46 deletions.
10 changes: 9 additions & 1 deletion eitprocessing/features/pixel_inflation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ def find_pixel_inflations(
end = start[1:]
middle = _find_extreme_indices(pixel_impedance, start, row, col, mode_middle)

inflations = _compute_inflations(start, middle, end, time)
## To discuss: this block of code is implemented to prevent noisy pixels from breaking the code.
# Quick solve is to make entire breath object None if any breath in a pixel does not have
# consecutive start, middle and end.
# However, this might cause problems elsewhere.

if (start[:-1] >= middle).any() or (middle >= end).any():
inflations = None
else:
inflations = _compute_inflations(start, middle, end, time)
else:
inflations = None

Expand Down
68 changes: 34 additions & 34 deletions notebooks/test_parameter_tiv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 18,
"id": "58e6580f",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -31,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 19,
"id": "00f8acd0",
"metadata": {},
"outputs": [],
Expand All @@ -41,7 +41,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 20,
"id": "5be01072",
"metadata": {},
"outputs": [],
Expand All @@ -62,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 21,
"id": "abe2e6c4",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -100,7 +100,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 22,
"id": "e066cdf0",
"metadata": {},
"outputs": [],
Expand All @@ -110,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 23,
"id": "34498075",
"metadata": {},
"outputs": [],
Expand All @@ -130,24 +130,24 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 24,
"id": "4ba241dd",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7fbca579b670>]"
"[<matplotlib.lines.Line2D at 0x7fe55fa90bb0>]"
]
},
"execution_count": 7,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "82a531e98dba4f6985eddeda2597dc34",
"model_id": "6fc5d214e3294227a40061797b663b77",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -185,7 +185,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 25,
"id": "58b7f389",
"metadata": {},
"outputs": [],
Expand All @@ -203,7 +203,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 26,
"id": "62913fd8",
"metadata": {},
"outputs": [],
Expand All @@ -214,24 +214,24 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 27,
"id": "38e86661",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7fbc56ed81c0>]"
"[<matplotlib.lines.Line2D at 0x7fe55f83e6e0>]"
]
},
"execution_count": 10,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3171130e6b1c417c8650b1fb9929b10e",
"model_id": "ce7c6dd0e4de44e4b213f3e496e623ae",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -288,7 +288,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 28,
"id": "b742f5e9",
"metadata": {},
"outputs": [],
Expand All @@ -303,24 +303,24 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 29,
"id": "7d4cc5da",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7fbc59fd5c90>]"
"[<matplotlib.lines.Line2D at 0x7fe55c71f790>]"
]
},
"execution_count": 12,
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c4d2c421166840779333c17f512d2091",
"model_id": "38c1199a679341c5bb019d57a22b3211",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -378,7 +378,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 30,
"id": "be28cb94",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -432,14 +432,14 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 31,
"id": "1231ccd7",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8d3f9b9f08ce4c56ba7dcdcfc64efcd6",
"model_id": "1fd60bf38b944355bbf6495ed20586c4",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -514,14 +514,14 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 32,
"id": "ee772f3f",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ba8ab0638ac44ca5b6d11d78aefb612e",
"model_id": "deedf7195fb349f4a12001f5b134a4f1",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -566,19 +566,19 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 33,
"id": "6ab8151c",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/var/folders/m6/wsm3_cgd0fx7zkm_j_sph5s00000gn/T/ipykernel_5306/2984198559.py:1: RuntimeWarning: Mean of empty slice\n",
"/var/folders/m6/wsm3_cgd0fx7zkm_j_sph5s00000gn/T/ipykernel_80329/2984198559.py:1: RuntimeWarning: Mean of empty slice\n",
" mean_tiv_map_inspiratory = np.nanmean(tiv_result_pixel_inspiratory, axis=0)\n",
"/var/folders/m6/wsm3_cgd0fx7zkm_j_sph5s00000gn/T/ipykernel_5306/2984198559.py:2: RuntimeWarning: Mean of empty slice\n",
"/var/folders/m6/wsm3_cgd0fx7zkm_j_sph5s00000gn/T/ipykernel_80329/2984198559.py:2: RuntimeWarning: Mean of empty slice\n",
" mean_tiv_map_expiratory = np.nanmean(tiv_result_pixel_expiratory, axis=0)\n",
"/var/folders/m6/wsm3_cgd0fx7zkm_j_sph5s00000gn/T/ipykernel_5306/2984198559.py:3: RuntimeWarning: Mean of empty slice\n",
"/var/folders/m6/wsm3_cgd0fx7zkm_j_sph5s00000gn/T/ipykernel_80329/2984198559.py:3: RuntimeWarning: Mean of empty slice\n",
" mean_tiv_map_mean = np.nanmean(tiv_result_pixel_mean, axis=0)\n"
]
}
Expand All @@ -591,24 +591,24 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 34,
"id": "7f36fb59",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fbc5b1a8b80>"
"<matplotlib.image.AxesImage at 0x7fe53e16e7d0>"
]
},
"execution_count": 17,
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8564cf906fce470680800d4b5880fd76",
"model_id": "3c4a3cd842d145149e7992cb6a1da5d5",
"version_major": 2,
"version_minor": 0
},
Expand Down
31 changes: 20 additions & 11 deletions notebooks/test_pixel_inflation.ipynb

Large diffs are not rendered by default.

0 comments on commit 36ddb7a

Please sign in to comment.