Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MPBA Radiomics
RADLER
Commits
577832a7
Commit
577832a7
authored
Oct 16, 2019
by
Alessia Marcolini
Browse files
Save labels as str
parent
0cc3ac68
Changes
1
Hide whitespace changes
Inline
Side-by-side
preprocessing/group_T-stage.ipynb
View file @
577832a7
...
...
@@ -298,24 +298,24 @@
},
{
"cell_type": "code",
"execution_count":
11
,
"execution_count":
7
,
"metadata": {},
"outputs": [],
"source": [
"grading_dict = {\n",
" 'T1':
0
,\n",
" 'T2':
0
,\n",
" 'T3':
1
,\n",
" 'T4':
1
,\n",
" 'T4a':
1
,\n",
" 'T4b':
1
,\n",
" 'Tx':
1
,\n",
" 'T1':
'0'
,\n",
" 'T2':
'0'
,\n",
" 'T3':
'1'
,\n",
" 'T4':
'1'
,\n",
" 'T4a':
'1'
,\n",
" 'T4b':
'1'
,\n",
" 'Tx':
'1'
,\n",
"}"
]
},
{
"cell_type": "code",
"execution_count":
12
,
"execution_count":
8
,
"metadata": {},
"outputs": [],
"source": [
...
...
%% Cell type:code id: tags:
```
python
%
HN_env
```
%% Output
<IPython.core.display.HTML object>
%% Cell type:code id: tags:
```
python
import
os
# base path of the project
PATH
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
curdir
),
'..'
)
```
%% Cell type:code id: tags:
```
python
import
numpy
as
np
import
pandas
as
pd
```
%% Cell type:code id: tags:
```
python
clinical
=
pd
.
read_csv
(
f
'
{
PATH
}
/data/clinical_data.csv'
)
```
%% Cell type:code id: tags:
```
python
clinical
.
head
()
```
%% Output
Patient # Sex Age Primary Site T-stage N-stage M-stage TNM group stage \
0 HN-HGJ-001 M 79.0 Larynx T3 N0 M0 stage III
1 HN-HGJ-002 M 41.0 Nasopharynx T1 N1 M0 stage IIB
2 HN-HGJ-003 M 75.0 Larynx T3 N2b M0 stage IVA
3 HN-HGJ-004 M 53.0 Nasopharynx T3 N1 M0 stage III
4 HN-HGJ-005 M 74.0 Nasopharynx T1 N1 M0 stage IIB
HPV status Time – diagnosis to diagnosis (days) ... Surgery \
0 - 0 ... 0.0
1 - 0 ... 0.0
2 NaN 0 ... 0.0
3 NaN 0 ... 0.0
4 - 0 ... 0.0
Time – diagnosis to last follow-up(days) Locoregional Distant Death \
0 2123 1 0 0
1 2114 1 0 0
2 1098 1 1 1
3 2974 0 0 0
4 2509 0 0 1
Time – diagnosis to LR (days) Time – diagnosis to DM (days) \
0 692.0 NaN
1 918.0 NaN
2 441.0 441.0
3 NaN NaN
4 NaN NaN
Time – diagnosis to Death (days) stage stage_simple
0 NaN III III
1 NaN IIB II
2 1098.0 IVA IV
3 NaN III III
4 2509.0 IIB II
[5 rows x 25 columns]
%% Cell type:code id: tags:
```
python
pd
.
unique
(
clinical
[
'T-stage'
].
values
)
```
%% Output
array(['T3', 'T1', 'T4', 'T2', 'Tx', 'T4b', 'T4a'], dtype=object)
%% Cell type:code id: tags:
```
python
grading_dict
=
{
'T1'
:
0
,
'T2'
:
0
,
'T3'
:
1
,
'T4'
:
1
,
'T4a'
:
1
,
'T4b'
:
1
,
'Tx'
:
1
,
'T1'
:
'0'
,
'T2'
:
'0'
,
'T3'
:
'1'
,
'T4'
:
'1'
,
'T4a'
:
'1'
,
'T4b'
:
'1'
,
'Tx'
:
'1'
,
}
```
%% Cell type:code id: tags:
```
python
clinical
[
'T-stage_grouped'
]
=
clinical
[
'T-stage'
].
apply
(
lambda
x
:
grading_dict
[
x
])
```
%% Cell type:code id: tags:
```
python
clinical
.
head
()
```
%% Output
Patient # Sex Age Primary Site T-stage N-stage M-stage TNM group stage \
0 HN-HGJ-001 M 79.0 Larynx T3 N0 M0 stage III
1 HN-HGJ-002 M 41.0 Nasopharynx T1 N1 M0 stage IIB
2 HN-HGJ-003 M 75.0 Larynx T3 N2b M0 stage IVA
3 HN-HGJ-004 M 53.0 Nasopharynx T3 N1 M0 stage III
4 HN-HGJ-005 M 74.0 Nasopharynx T1 N1 M0 stage IIB
HPV status Time – diagnosis to diagnosis (days) ... \
0 - 0 ...
1 - 0 ...
2 NaN 0 ...
3 NaN 0 ...
4 - 0 ...
Time – diagnosis to last follow-up(days) Locoregional Distant Death \
0 2123 1 0 0
1 2114 1 0 0
2 1098 1 1 1
3 2974 0 0 0
4 2509 0 0 1
Time – diagnosis to LR (days) Time – diagnosis to DM (days) \
0 692.0 NaN
1 918.0 NaN
2 441.0 441.0
3 NaN NaN
4 NaN NaN
Time – diagnosis to Death (days) stage stage_simple T-stage_grouped
0 NaN III III 1
1 NaN IIB II 0
2 1098.0 IVA IV 1
3 NaN III III 1
4 2509.0 IIB II 0
[5 rows x 26 columns]
%% Cell type:code id: tags:
```
python
clinical
.
to_csv
(
f
'
{
PATH
}
/data/clinical_data.csv'
,
index
=
False
)
```
%% Cell type:code id: tags:
```
python
```
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment