Skip to content

Commit

Permalink
Release v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lucalianas committed Nov 28, 2020
2 parents b554d53 + eeff9e5 commit 0bbbc56
Show file tree
Hide file tree
Showing 17 changed files with 204 additions and 44 deletions.
2 changes: 1 addition & 1 deletion promort/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.4
0.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def _dump_data(self, page_size, csv_writer):
self._dump_row(ca, csv_writer)

def _dump_row(self, core_annotation, csv_writer):
try:
creation_start_date = core_annotation.creation_start_date.strftime('%Y-%m-%d %H:%M:%S')
except AttributeError:
creation_start_date = None
csv_writer.writerow(
{
'case_id': core_annotation.core.slice.slide.case.id,
Expand All @@ -65,6 +69,7 @@ def _dump_row(self, core_annotation, csv_writer):
'reviewer': core_annotation.author.username,
'core_id': core_annotation.core.id,
'core_label': core_annotation.core.label,
'creation_start_date': creation_start_date,
'creation_date': core_annotation.creation_date.strftime('%Y-%m-%d %H:%M:%S'),
'primary_gleason': core_annotation.primary_gleason,
'secondary_gleason': core_annotation.secondary_gleason,
Expand All @@ -74,8 +79,8 @@ def _dump_row(self, core_annotation, csv_writer):

def _export_data(self, out_file, page_size):
header = ['case_id', 'slide_id', 'rois_review_step_id', 'clinical_review_step_id', 'reviewer',
'core_id', 'core_label', 'creation_date', 'primary_gleason', 'secondary_gleason',
'gleason_group_who_16']
'core_id', 'core_label', 'creation_start_date', 'creation_date', 'primary_gleason',
'secondary_gleason', 'gleason_group_who_16']
with open(out_file, 'w') as ofile:
writer = DictWriter(ofile, delimiter=',', fieldnames=header)
writer.writeheader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def _dump_data(self, page_size, csv_writer):
self._dump_row(fra, csv_writer)

def _dump_row(self, focus_region_annotation, csv_writer):
try:
creation_start_date = focus_region_annotation.creation_start_date.strftime('%Y-%m-%d %H:%M:%S')
except AttributeError:
creation_start_date = None
csv_writer.writerow(
{
'case_id': focus_region_annotation.focus_region.core.slice.slide.case.id,
Expand All @@ -66,6 +70,7 @@ def _dump_row(self, focus_region_annotation, csv_writer):
'focus_region_label': focus_region_annotation.focus_region.label,
'core_id': focus_region_annotation.focus_region.core.id,
'core_label': focus_region_annotation.focus_region.core.label,
'creation_start_date': creation_start_date,
'creation_date': focus_region_annotation.creation_date.strftime('%Y-%m-%d %H:%M:%S'),
'perineural_involvement': focus_region_annotation.perineural_involvement,
'intraductal_carcinoma': focus_region_annotation.intraductal_carcinoma,
Expand All @@ -83,9 +88,9 @@ def _dump_row(self, focus_region_annotation, csv_writer):

def _export_data(self, out_file, page_size):
header = ['case_id', 'slide_id', 'rois_review_step_id', 'clinical_review_step_id', 'reviewer',
'focus_region_id', 'focus_region_label', 'core_id', 'core_label', 'creation_date',
'perineural_involvement', 'intraductal_carcinoma', 'ductal_carcinoma', 'poorly_formed_glands',
'cribriform_pattern', 'small_cell_signet_ring', 'hypernephroid_pattern',
'focus_region_id', 'focus_region_label', 'core_id', 'core_label', 'creation_start_date',
'creation_date', 'perineural_involvement', 'intraductal_carcinoma', 'ductal_carcinoma',
'poorly_formed_glands', 'cribriform_pattern', 'small_cell_signet_ring', 'hypernephroid_pattern',
'mucinous', 'comedo_necrosis', 'total_gleason_4_area', 'gleason_4_percentage']
with open(out_file, 'w') as ofile:
writer = DictWriter(ofile, delimiter=',', fieldnames=header)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def _dump_data(self, page_size, csv_writer):
self._dump_row(sa, csv_writer)

def _dump_row(self, slice_annotation, csv_writer):
try:
creation_start_date = slice_annotation.creation_start_date.strftime('%Y-%m-%d %H:%M:%S')
except AttributeError:
creation_start_date = None
csv_writer.writerow(
{
'case_id': slice_annotation.slice.slide.case.id,
Expand All @@ -65,6 +69,7 @@ def _dump_row(self, slice_annotation, csv_writer):
'reviewer': slice_annotation.author.username,
'slice_id': slice_annotation.slice.id,
'slice_label': slice_annotation.slice.label,
'creation_start_date': creation_start_date,
'creation_date': slice_annotation.creation_date.strftime('%Y-%m-%d %H:%M:%S'),
'high_grade_pin': slice_annotation.high_grade_pin,
'pah': slice_annotation.pah,
Expand All @@ -78,8 +83,8 @@ def _dump_row(self, slice_annotation, csv_writer):

def _export_data(self, out_file, page_size):
header = ['case_id', 'slide_id', 'rois_review_step_id', 'clinical_review_step_id', 'reviewer',
'slice_id', 'slice_label', 'creation_date', 'high_grade_pin', 'pah', 'chronic_inflammation',
'acute_inflammation', 'periglandular_inflammation',
'slice_id', 'slice_label', 'creation_start_date', 'creation_date', 'high_grade_pin', 'pah',
'chronic_inflammation', 'acute_inflammation', 'periglandular_inflammation',
'intraglandular_inflammation', 'stromal_inflammation']
with open(out_file, 'w') as ofile:
writer = DictWriter(ofile, delimiter=',', fieldnames=header)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-11-24 08:32
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('clinical_annotations_manager', '0015_gleasonelement_creation_date'),
]

operations = [
migrations.AddField(
model_name='coreannotation',
name='creation_start_date',
field=models.DateTimeField(default=None, null=True),
),
migrations.AddField(
model_name='focusregionannotation',
name='creation_start_date',
field=models.DateTimeField(default=None, null=True),
),
migrations.AddField(
model_name='gleasonelement',
name='creation_start_date',
field=models.DateTimeField(default=None, null=True),
),
migrations.AddField(
model_name='sliceannotation',
name='creation_start_date',
field=models.DateTimeField(default=None, null=True),
),
]
4 changes: 4 additions & 0 deletions promort/clinical_annotations_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SliceAnnotation(models.Model):
related_name='clinical_annotations')
annotation_step = models.ForeignKey(ClinicalAnnotationStep, on_delete=models.PROTECT,
blank=False, related_name='slice_annotations')
creation_start_date = models.DateTimeField(null=True, default=None)
creation_date = models.DateTimeField(default=timezone.now)
high_grade_pin = models.BooleanField(blank=False, null=False, default=False)
pah = models.BooleanField(blank=False, null=False, default=False)
Expand Down Expand Up @@ -84,6 +85,7 @@ class CoreAnnotation(models.Model):
related_name='clinical_annotations')
annotation_step = models.ForeignKey(ClinicalAnnotationStep, on_delete=models.PROTECT,
blank=False, related_name='core_annotations')
creation_start_date = models.DateTimeField(null=True, default=None)
creation_date = models.DateTimeField(default=timezone.now)
primary_gleason = models.IntegerField(blank=False)
secondary_gleason = models.IntegerField(blank=False)
Expand Down Expand Up @@ -130,6 +132,7 @@ class FocusRegionAnnotation(models.Model):
blank=False, related_name='clinical_annotations')
annotation_step = models.ForeignKey(ClinicalAnnotationStep, on_delete=models.PROTECT,
blank=False, related_name='focus_region_annotations')
creation_start_date = models.DateTimeField(null=True, default=None)
creation_date = models.DateTimeField(default=timezone.now)
# cancerous region fields
perineural_involvement = models.BooleanField(blank=False, null=False, default=False)
Expand Down Expand Up @@ -187,6 +190,7 @@ class GleasonElement(models.Model):
cellular_density_helper_json = models.TextField(blank=True, null=True)
cellular_density = models.IntegerField(blank=True, null=True)
cells_count = models.IntegerField(blank=True, null=True)
creation_start_date = models.DateTimeField(null=True, default=None)
creation_date = models.DateTimeField(default=timezone.now)

def get_gleason_type_label(self):
Expand Down
16 changes: 8 additions & 8 deletions promort/clinical_annotations_manager/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SliceAnnotationSerializer(serializers.ModelSerializer):

class Meta:
model = SliceAnnotation
fields = ('id', 'author', 'slice', 'annotation_step', 'creation_date', 'high_grade_pin',
fields = ('id', 'author', 'slice', 'annotation_step', 'creation_start_date', 'creation_date', 'high_grade_pin',
'pah', 'chronic_inflammation', 'acute_inflammation', 'periglandular_inflammation',
'intraglandular_inflammation', 'stromal_inflammation', 'gleason_4_percentage')
read_only_fields = ('id', 'creation_date', 'gleason_4_percentage')
Expand Down Expand Up @@ -73,7 +73,7 @@ class CoreAnnotationSerializer(serializers.ModelSerializer):

class Meta:
model = CoreAnnotation
fields = ('id', 'author', 'core', 'annotation_step', 'creation_date', 'primary_gleason',
fields = ('id', 'author', 'core', 'annotation_step', 'creation_start_date', 'creation_date', 'primary_gleason',
'secondary_gleason', 'gleason_score', 'gleason_4_percentage', 'gleason_group')
read_only_fields = ('id', 'creation_date', 'gleason_score', 'gleason_4_percentage')
write_only_fields = ('annotation_step',)
Expand Down Expand Up @@ -105,7 +105,7 @@ class Meta:
model = GleasonElement
fields = ('id', 'gleason_type', 'gleason_label', 'json_path', 'area',
'cellular_density_helper_json', 'cellular_density', 'cells_count',
'creation_date')
'creation_date', 'creation_start_date')
read_only_fields = ('gleason_label',)

@staticmethod
Expand Down Expand Up @@ -140,11 +140,11 @@ class FocusRegionAnnotationSerializer(serializers.ModelSerializer):

class Meta:
model = FocusRegionAnnotation
fields = ('id', 'author', 'focus_region', 'annotation_step', 'creation_date', 'perineural_involvement',
'intraductal_carcinoma', 'ductal_carcinoma', 'poorly_formed_glands', 'cribriform_pattern',
'small_cell_signet_ring', 'hypernephroid_pattern', 'mucinous', 'comedo_necrosis',
'inflammation', 'pah', 'atrophic_lesions', 'adenosis', 'cellular_density_helper_json',
'cellular_density', 'cells_count', 'gleason_elements')
fields = ('id', 'author', 'focus_region', 'annotation_step', 'creation_start_date', 'creation_date',
'perineural_involvement', 'intraductal_carcinoma', 'ductal_carcinoma', 'poorly_formed_glands',
'cribriform_pattern', 'small_cell_signet_ring', 'hypernephroid_pattern', 'mucinous',
'comedo_necrosis', 'inflammation', 'pah', 'atrophic_lesions', 'adenosis',
'cellular_density_helper_json', 'cellular_density', 'cells_count', 'gleason_elements')
read_only_fields = ('creation_date',)
write_only_fields = ('id', 'annotation_step', 'gleason_elements', 'author')

Expand Down
9 changes: 7 additions & 2 deletions promort/rois_manager/management/commands/get_cores_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def _dump_data(self, page_size, csv_writer):
self._dump_row(c, csv_writer)

def _dump_row(self, core, csv_writer):
try:
creation_start_date = core.creation_start_date.strftime('%Y-%m-%d %H:%M:%S')
except AttributeError:
creation_start_date = None
csv_writer.writerow(
{
'case_id': core.slice.slide.case.id,
Expand All @@ -64,6 +68,7 @@ def _dump_row(self, core, csv_writer):
'parent_slice_id': core.slice.id,
'core_label': core.label,
'core_id': core.id,
'creation_start_date': creation_start_date,
'creation_date': core.creation_date.strftime('%Y-%m-%d %H:%M:%S'),
'reviewer': core.author.username,
'length': core.length,
Expand All @@ -76,8 +81,8 @@ def _dump_row(self, core, csv_writer):
)

def _export_data(self, out_file, page_size):
header = ['case_id', 'slide_id', 'roi_review_step_id', 'parent_slice_id',
'core_label', 'core_id', 'creation_date', 'reviewer', 'length', 'area', 'tumor_length',
header = ['case_id', 'slide_id', 'roi_review_step_id', 'parent_slice_id', 'core_label', 'core_id',
'creation_start_date', 'creation_date', 'reviewer', 'length', 'area', 'tumor_length',
'positive_core', 'normal_tissue_percentage', 'total_tumor_area']
with open(out_file, 'w') as ofile:
writer = DictWriter(ofile, delimiter=',', fieldnames=header)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def _dump_data(self, page_size, csv_writer):
self._dump_row(fr, csv_writer)

def _dump_row(self, focus_region, csv_writer):
try:
creation_start_date = focus_region.creation_start_date.strftime('%Y-%m-%d %H:%M:%S')
except AttributeError:
creation_start_date = None
csv_writer.writerow(
{
'case_id': focus_region.core.slice.slide.case.id,
Expand All @@ -65,6 +69,7 @@ def _dump_row(self, focus_region, csv_writer):
'parent_core_label': focus_region.core.label,
'focus_region_label': focus_region.label,
'focus_region_id': focus_region.id,
'creation_start_date': creation_start_date,
'creation_date': focus_region.creation_date.strftime('%Y-%m-%d %H:%M:%S'),
'reviewer': focus_region.author.username,
'length': focus_region.length,
Expand All @@ -84,7 +89,7 @@ def _get_region_tissue_status(self, focus_region):

def _export_data(self, out_file, page_size):
header = ['case_id', 'slide_id', 'rois_review_step_id', 'parent_core_id', 'parent_core_label',
'focus_region_label', 'focus_region_id', 'creation_date', 'reviewer', 'length',
'focus_region_label', 'focus_region_id', 'creation_start_date', 'creation_date', 'reviewer', 'length',
'area', 'tissue_status', 'core_coverage_percentage']
with open(out_file, 'w') as ofile:
writer = DictWriter(ofile, delimiter=',', fieldnames=header)
Expand Down
9 changes: 7 additions & 2 deletions promort/rois_manager/management/commands/get_slices_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ def _dump_data(self, page_size, csv_writer):
self._dump_row(s, csv_writer)

def _dump_row(self, slice, csv_writer):
try:
creation_start_date = slice.creation_start_date.strftime('%Y-%m-%d %H:%M:%S')
except AttributeError:
creation_start_date = None
csv_writer.writerow(
{
'case_id': slice.slide.case.id,
'slide_id': slice.slide.id,
'roi_review_step_id': slice.annotation_step.label,
'slice_label': slice.label,
'slice_id': slice.id,
'creation_start_date': creation_start_date,
'creation_date': slice.creation_date.strftime('%Y-%m-%d %H:%M:%S'),
'reviewer': slice.author.username,
'positive_slice': slice.is_positive(),
Expand All @@ -72,8 +77,8 @@ def _dump_row(self, slice, csv_writer):
)

def _export_data(self, out_file, page_size):
header = ['case_id', 'slide_id', 'roi_review_step_id', 'slice_label', 'slice_id', 'creation_date',
'reviewer', 'positive_slice', 'positive_cores', 'total_cores']
header = ['case_id', 'slide_id', 'roi_review_step_id', 'slice_label', 'slice_id', 'creation_start_date',
'creation_date', 'reviewer', 'positive_slice', 'positive_cores', 'total_cores']
with open(out_file, 'w') as ofile:
writer = DictWriter(ofile, delimiter=',', fieldnames=header)
writer.writeheader()
Expand Down
30 changes: 30 additions & 0 deletions promort/rois_manager/migrations/0019_auto_20201123_0925.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-11-23 09:25
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('rois_manager', '0018_remove_focusregion_cancerous_region'),
]

operations = [
migrations.AddField(
model_name='core',
name='craetion_start_date',
field=models.DateTimeField(default=None, null=True),
),
migrations.AddField(
model_name='focusregion',
name='creation_start_date',
field=models.DateTimeField(default=None, null=True),
),
migrations.AddField(
model_name='slice',
name='creation_start_date',
field=models.DateTimeField(default=None, null=True),
),
]
20 changes: 20 additions & 0 deletions promort/rois_manager/migrations/0020_auto_20201123_1615.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-11-23 16:15
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('rois_manager', '0019_auto_20201123_0925'),
]

operations = [
migrations.RenameField(
model_name='core',
old_name='craetion_start_date',
new_name='creation_start_date',
),
]
3 changes: 3 additions & 0 deletions promort/rois_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Slice(models.Model):
author = models.ForeignKey(User, on_delete=models.PROTECT, blank=False)
annotation_step = models.ForeignKey(ROIsAnnotationStep, on_delete=models.PROTECT,
blank=False, related_name='slices')
creation_start_date = models.DateTimeField(null=True, default=None)
creation_date = models.DateTimeField(auto_now_add=True)
roi_json = models.TextField(blank=False)
total_cores = models.IntegerField(blank=False, default=0)
Expand Down Expand Up @@ -62,6 +63,7 @@ class Core(models.Model):
blank=False, related_name='cores')
author = models.ForeignKey(User, on_delete=models.PROTECT,
blank=False)
creation_start_date = models.DateTimeField(null=True, default=None)
creation_date = models.DateTimeField(auto_now_add=True)
roi_json = models.TextField(blank=False)
length = models.FloatField(blank=False, default=0.0)
Expand Down Expand Up @@ -101,6 +103,7 @@ class FocusRegion(models.Model):
blank=False, related_name='focus_regions')
author = models.ForeignKey(User, on_delete=models.PROTECT,
blank=False)
creation_start_date = models.DateTimeField(null=True, default=None)
creation_date = models.DateTimeField(auto_now_add=True)
roi_json = models.TextField(blank=False)
length = models.FloatField(blank=False, default=0.0)
Expand Down
Loading

0 comments on commit 0bbbc56

Please sign in to comment.