{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from p2ch10.dsets import getCandidateInfoList, getCt, LunaDataset\n", "candidateInfo_list = getCandidateInfoList(requireOnDisk_bool=False)\n", "positiveInfo_list = [x for x in candidateInfo_list if x[0]]\n", "diameter_list = [x[1] for x in positiveInfo_list]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1351\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=32.27003025, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.287966244644280690737019247886', center_xyz=(67.61451718, 85.02525992, -109.8084416))\n" ] } ], "source": [ "print(len(positiveInfo_list))\n", "print(positiveInfo_list[0])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 0 32.3 mm\n", " 100 17.7 mm\n", " 200 13.0 mm\n", " 300 10.0 mm\n", " 400 8.2 mm\n", " 500 7.0 mm\n", " 600 6.3 mm\n", " 700 5.7 mm\n", " 800 5.1 mm\n", " 900 4.7 mm\n", "1000 4.0 mm\n", "1100 0.0 mm\n", "1200 0.0 mm\n", "1300 0.0 mm\n" ] } ], "source": [ "for i in range(0, len(diameter_list), 100):\n", " print('{:4} {:4.1f} mm'.format(i, diameter_list[i]))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CandidateInfoTuple(isNodule_bool=True, diameter_mm=32.27003025, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.287966244644280690737019247886', center_xyz=(67.61451718, 85.02525992, -109.8084416))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=30.61040636, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.112740418331256326754121315800', center_xyz=(47.90350511, 37.60442008, -99.93417567))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=30.61040636, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.112740418331256326754121315800', center_xyz=(44.19, 37.79, -107.01))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=30.61040636, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.112740418331256326754121315800', center_xyz=(40.69, 32.19, -97.15))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=27.44242293, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.943403138251347598519939390311', center_xyz=(-45.29440163, 74.86925386, -97.52812481))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=27.07544345, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.481278873893653517789960724156', center_xyz=(-102.571208, -5.186558766, -205.1033412))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=26.83708074, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.487268565754493433372433148666', center_xyz=(121.152909372, 12.9136003304, -159.399497186))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=26.83708074, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.487268565754493433372433148666', center_xyz=(118.8539408, 11.54202797, -165.5042458))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=25.87269662, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.177086402277715068525592995222', center_xyz=(-66.628286875, 57.151972075, -110.12035075))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=25.41540526, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.219618492426142913407827034169', center_xyz=(-101.7504204, -95.65460516, -138.4943211))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.107109359065300889765026303943', center_xyz=(-100.57, -66.23, -218.76))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.106379658920626694402549886949', center_xyz=(-71.09, 68.3, -160.4))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408431413578140925249', center_xyz=(106.18, 12.61, -96.81))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408431413578140925249', center_xyz=(96.2846726653, 19.0348690723, -88.478440818))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(89.32, 190.84, -516.82))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(89.32, 143.23, -427.1))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(85.12, 152.33, -425.7))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(8.8, 174.74, -401.87))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(5.99, 171.94, -398.37))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(1.79, 166.34, -408.88))\n", "CandidateInfoTuple(isNodule_bool=True, diameter_mm=0.0, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.124154461048929153767743874565', center_xyz=(146.12, -160.55, -309.93))\n" ] } ], "source": [ "for candidateInfo_tup in positiveInfo_list[:10]:\n", " print(candidateInfo_tup)\n", "for candidateInfo_tup in positiveInfo_list[-10:]:\n", " print(candidateInfo_tup)\n", " \n", "for candidateInfo_tup in positiveInfo_list:\n", " if candidateInfo_tup.series_uid.endswith('565'):\n", " print(candidateInfo_tup)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([323, 466, 248, 111, 71, 57, 37, 29, 5, 4], dtype=int64),\n", " array([ 0. , 3.22700302, 6.45400605, 9.68100907, 12.9080121 ,\n", " 16.13501512, 19.36201815, 22.58902117, 25.8160242 , 29.04302722,\n", " 32.27003025]))" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.histogram(diameter_list)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2020-07-26 14:43:07,854 INFO pid:9828 p2ch10.dsets:212:__init__ : 551065 training samples\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "0 CandidateInfoTuple(isNodule_bool=True, diameter_mm=32.27003025, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.287966244644280690737019247886', center_xyz=(67.61451718, 85.02525992, -109.8084416))\n", "1 CandidateInfoTuple(isNodule_bool=True, diameter_mm=30.61040636, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.112740418331256326754121315800', center_xyz=(47.90350511, 37.60442008, -99.93417567))\n", "2 CandidateInfoTuple(isNodule_bool=True, diameter_mm=30.61040636, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.112740418331256326754121315800', center_xyz=(44.19, 37.79, -107.01))\n", "3 CandidateInfoTuple(isNodule_bool=True, diameter_mm=30.61040636, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.112740418331256326754121315800', center_xyz=(40.69, 32.19, -97.15))\n", "4 CandidateInfoTuple(isNodule_bool=True, diameter_mm=27.44242293, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.943403138251347598519939390311', center_xyz=(-45.29440163, 74.86925386, -97.52812481))\n", "5 CandidateInfoTuple(isNodule_bool=True, diameter_mm=27.07544345, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.481278873893653517789960724156', center_xyz=(-102.571208, -5.186558766, -205.1033412))\n", "6 CandidateInfoTuple(isNodule_bool=True, diameter_mm=26.83708074, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.487268565754493433372433148666', center_xyz=(121.152909372, 12.9136003304, -159.399497186))\n", "7 CandidateInfoTuple(isNodule_bool=True, diameter_mm=26.83708074, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.487268565754493433372433148666', center_xyz=(118.8539408, 11.54202797, -165.5042458))\n", "8 CandidateInfoTuple(isNodule_bool=True, diameter_mm=25.87269662, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.177086402277715068525592995222', center_xyz=(-66.628286875, 57.151972075, -110.12035075))\n", "9 CandidateInfoTuple(isNodule_bool=True, diameter_mm=25.41540526, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.219618492426142913407827034169', center_xyz=(-101.7504204, -95.65460516, -138.4943211))\n", "10 CandidateInfoTuple(isNodule_bool=True, diameter_mm=25.23320204, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.511347030803753100045216493273', center_xyz=(63.4740118048, 73.9174523314, -213.736128767))\n", "11 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.78201705, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.183982839679953938397312236359', center_xyz=(-44.69, 69.79, -149.72))\n", "12 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.78201705, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.183982839679953938397312236359', center_xyz=(-46.36896147, 64.20509868, -149.8345695))\n", "13 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.78201705, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.183982839679953938397312236359', center_xyz=(-51.69, 60.69, -151.84))\n", "14 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.77327957, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.146987333806092287055399155268', center_xyz=(97.3540746077, -16.7922286632, -263.659908373))\n", "15 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.77327957, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.146987333806092287055399155268', center_xyz=(96.9273129009, -25.9394823208, -259.572637924))\n", "16 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.77327957, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.146987333806092287055399155268', center_xyz=(96.7240184522, -15.392485207, -254.088367666))\n", "17 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.77327957, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.146987333806092287055399155268', center_xyz=(92.04749503, -21.50898302, -258.0493441))\n", "18 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.66335961, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.316900421002460665752357657094', center_xyz=(-101.02413021, -46.3316843088, -138.184349429))\n", "19 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.28186352, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.153985109349433321657655488650', center_xyz=(-31.27671425, 50.03085749, -62.114861675))\n", "20 CandidateInfoTuple(isNodule_bool=True, diameter_mm=24.28186352, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.153985109349433321657655488650', center_xyz=(-35.8713914979, 44.7804912383, -64.3671546075))\n", "21 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.93362973, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.267957701183569638795986183786', center_xyz=(-93.56243383, -176.0629504, 213.322413))\n", "22 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.93362973, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.267957701183569638795986183786', center_xyz=(-97.37, -178.69, 207.83))\n", "23 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.80291305, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.997611074084993415992563148335', center_xyz=(-23.71929698, 31.71448919, -156.1722334))\n", "24 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.68811013, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.194766721609772924944646251928', center_xyz=(-110.51142385, 8.69531556, -123.28560915))\n", "25 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.57156231, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.220596530836092324070084384692', center_xyz=(-83.80648889, 247.1206328, -508.1281928))\n", "26 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.48374545, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.148447286464082095534651426689', center_xyz=(-90.1922382588, 32.9077042197, -127.738768532))\n", "27 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.48374545, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.148447286464082095534651426689', center_xyz=(-93.9441715503, 28.8165564567, -130.21511348))\n", "28 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.35064438, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192', center_xyz=(57.42, 81.14, -118.09))\n", "29 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.35064438, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192', center_xyz=(56.4889724157, 85.9418105037, -115.9731945))\n", "30 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.35064438, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192', center_xyz=(50.4361084414, 90.0424445754, -113.908439345))\n", "31 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.35064438, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.179049373636438705059720603192', center_xyz=(50.42, 85.34, -118.09))\n", "32 CandidateInfoTuple(isNodule_bool=True, diameter_mm=23.04344837, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.329404588567903628160652715124', center_xyz=(37.5974516166, -29.0404354588, -89.5895072532))\n", "33 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.88079244, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.272348349298439120568330857680', center_xyz=(-47.99377473, 46.12731074, -87.873371315))\n", "34 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.78152704, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.487745546557477250336016826588', center_xyz=(52.18, -21.02, -81.16))\n", "35 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.78152704, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.487745546557477250336016826588', center_xyz=(47.91906761, -15.33163049, -79.39068082))\n", "36 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.77961842, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.280072876841890439628529365478', center_xyz=(106.735462, -126.2609139, -246.7420448))\n", "37 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.77961842, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.280072876841890439628529365478', center_xyz=(105.333333214, -122.206423177, -250.179791813))\n", "38 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.46928325, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.323408652979949774528873200770', center_xyz=(71.85144885, -14.25481301, -196.650432))\n", "39 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.30485311, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.300136985030081433029390459071', center_xyz=(120.7322104, 8.225171006, -225.9610159))\n", "40 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.23698113, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.613212850444255764524630781782', center_xyz=(-25.152181, 22.59259632, -187.736925))\n", "41 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.22543938, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.286422846896797433168187085942', center_xyz=(-89.5875500717, 11.3033645407, -70.9842087538))\n", "42 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.13533119, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.272123398257168239653655006815', center_xyz=(127.381224886, 35.3882732546, -227.662204027))\n", "43 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.13322034, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.121391737347333465796214915391', center_xyz=(51.27, -67.3, -117.57))\n", "44 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.13322034, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.121391737347333465796214915391', center_xyz=(46.423809125, -64.87603544, -122.4506795))\n", "45 CandidateInfoTuple(isNodule_bool=True, diameter_mm=22.03891888, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.272344603176687884771013620823', center_xyz=(96.97240574, 1.775612227, -113.0049791))\n", "46 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.87973183, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.625270601160880745954773142570', center_xyz=(-108.2007072, 46.48017452, -143.2481594))\n", "47 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.87973183, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.625270601160880745954773142570', center_xyz=(-109.95, 40.62, -145.83))\n", "48 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.82795321, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.123697637451437522065941162930', center_xyz=(-128.341115395, -14.2479988938, -77.7156132477))\n", "49 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.67749437, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.306948744223170422945185006551', center_xyz=(115.8300923, -1.798282385, -208.7569347))\n", "50 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.58311204, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.905371958588660410240398317235', center_xyz=(109.142472723, 49.6356928166, -121.183579092))\n", "51 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.57854728, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.624425075947752229712087113746', center_xyz=(-72.66975017, -60.94410393, -262.0051515))\n", "52 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.47561299, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.169128136262002764211589185953', center_xyz=(54.4462360178, 10.0927486763, -36.7112190437))\n", "53 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.45372882, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.170706757615202213033480003264', center_xyz=(72.1526638728, 77.4822388214, -193.387020499))\n", "54 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.34312682, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.675543413149938600000570588203', center_xyz=(106.744776799, -104.042070817, -208.328811627))\n", "55 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.25611171, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.163901773171373940247829492387', center_xyz=(-62.43562668, 40.89339483, -418.7333581))\n", "56 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.08961863, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408431413578140925249', center_xyz=(104.81380335, 20.8385087972, -92.6909672057))\n", "57 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.08245746, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.323753921818102744511069914832', center_xyz=(97.0113860538, 57.5982093699, -278.590343715))\n", "58 CandidateInfoTuple(isNodule_bool=True, diameter_mm=21.08245746, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.323753921818102744511069914832', center_xyz=(94.13, 58.79, -283.32))\n", "59 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.91111634, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.741709061958490690246385302477', center_xyz=(113.897541, -22.39244268, -162.31478))\n", "60 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.91111634, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.741709061958490690246385302477', center_xyz=(110.203735675, -20.1807410084, -165.26117976))\n", "61 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.88367551, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.616033753016904899083676284739', center_xyz=(-39.40689448, 112.1820721, -174.0780178))\n", "62 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.52475616, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.198698492013538481395497694975', center_xyz=(67.1465716505, 69.5146890415, -217.556904881))\n", "63 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.4841094, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.167237290696350215427953159586', center_xyz=(-89.45197187, -12.46417869, -122.368542))\n", "64 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.41212558, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.206097113343059612247503064658', center_xyz=(67.7764023684, -122.674798775, -155.064786875))\n", "65 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.38922514, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.271307051432838466826189754230', center_xyz=(124.3919697, -5.470035499, -263.7667514))\n", "66 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.38922514, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.271307051432838466826189754230', center_xyz=(120.809702607, -3.01965540139, -258.826817821))\n", "67 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.15998367, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.194632613233275988184244485809', center_xyz=(-47.08080052, -10.14514114, -95.64764905))\n", "68 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.11629595, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.655242448149322898770987310561', center_xyz=(-50.67176053, -13.36207647, -308.4063333))\n", "69 CandidateInfoTuple(isNodule_bool=True, diameter_mm=20.03584717, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.272123398257168239653655006815', center_xyz=(107.311250506, -0.937213524814, -188.600748396))\n", "70 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.92726356, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.948414623428298219623354433437', center_xyz=(-42.134598795, -37.86320447, -124.4268055))\n", "71 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.91668687, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.217955041973656886482758642958', center_xyz=(-44.41190009, 56.88723854, -48.55486639))\n", "72 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.84919656, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.211956804948320236390242845468', center_xyz=(46.1665905401, 170.74564813, -528.435433467))\n", "73 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.65387738, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.752756872840730509471096155114', center_xyz=(56.1226132601, 67.868268695, -65.6269886453))\n", "74 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.57555466, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.252634638822000832774167856951', center_xyz=(60.4248994838, 67.1512058204, -99.1406061111))\n", "75 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.34841823, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.198698492013538481395497694975', center_xyz=(82.81, -15.75, -162.89))\n", "76 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.34841823, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.198698492013538481395497694975', center_xyz=(77.2727775603, -16.7787004936, -164.485662499))\n", "77 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.310152, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.259123825760999546551970425757', center_xyz=(-41.68688864, 177.8605527, -381.5487979))\n", "78 CandidateInfoTuple(isNodule_bool=True, diameter_mm=19.0442187, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.173931884906244951746140865701', center_xyz=(75.83954427, 85.728505625, -193.82938625))\n", "79 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.99864751, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.290135156874098366424871975734', center_xyz=(-58.9822830798, 92.211052775, -217.824186038))\n", "80 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.98004463, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.948414623428298219623354433437', center_xyz=(-80.52844797, 23.70176427, -183.1614706))\n", "81 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.86783511, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.323408652979949774528873200770', center_xyz=(75.3236441, 30.87016712, -101.1660698))\n", "82 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.86783511, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.323408652979949774528873200770', center_xyz=(70.8255923438, 27.9653840377, -101.655301073))\n", "83 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.82522399, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.204802250386343794613980417281', center_xyz=(103.538289264, -149.865277714, -168.620028573))\n", "84 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.82522399, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.204802250386343794613980417281', center_xyz=(99.91284756, -146.2387841, -169.4623634))\n", "85 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.79314938, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.143622857676008763729469324839', center_xyz=(-77.05987845, -149.57574, -127.5254171))\n", "86 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.7832325, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.202811684116768680758082619196', center_xyz=(-82.79150362, -21.43587141, -97.18427459))\n", "87 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.67552564, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.970428941353693253759289796610', center_xyz=(-115.0750247, 64.37987761, -140.4059531))\n", "88 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.54514997, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(2.019565949, 172.5930677, -405.0528932))\n", "89 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.50978255, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.282512043257574309474415322775', center_xyz=(-87.764383255, 5.7813887, -184.80125035))\n", "90 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.40907555, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.613212850444255764524630781782', center_xyz=(-19.84160513, 34.92769866, -208.1710437))\n", "91 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.38478817, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.172243743899615313644757844726', center_xyz=(-132.919547876, 62.5582296311, -102.150007628))\n", "92 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.210145, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.287966244644280690737019247886', center_xyz=(102.8434969, 67.07660635, -238.6002813))\n", "93 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.20857028, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(94.93, 153.03, -429.91))\n", "94 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.20857028, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.100621383016233746780170740405', center_xyz=(90.7864693642, 148.811688395, -426.70448803))\n", "95 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.15623418, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.897684031374557757145405000951', center_xyz=(47.48394836, 186.8059443, -729.2846031))\n", "96 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.12790811, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.107109359065300889765026303943', center_xyz=(-97.54122491, -73.36723259, -222.9974028))\n", "97 CandidateInfoTuple(isNodule_bool=True, diameter_mm=18.02111617, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.257383535269991165447822992959', center_xyz=(-14.0390189941, 54.1839549346, -169.093320723))\n", "98 CandidateInfoTuple(isNodule_bool=True, diameter_mm=17.98864725, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.275007193025729362844652516689', center_xyz=(-29.34081638, -18.82685309, -134.5196606))\n", "99 CandidateInfoTuple(isNodule_bool=True, diameter_mm=17.75323185, series_uid='1.3.6.1.4.1.14519.5.2.1.6279.6001.187451715205085403623595258748', center_xyz=(94.1132711884, -15.8936132585, -202.847228297))\n" ] } ], "source": [ "from p2ch10.vis import findPositiveSamples, showCandidate\n", "positiveSample_list = findPositiveSamples()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2020-07-26 14:43:07,953 INFO pid:9828 p2ch10.dsets:212:__init__ : 602 training samples\n" ] }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
');\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " // select the cell after this one\n", " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", " IPython.notebook.select(index + 1);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "1.3.6.1.4.1.14519.5.2.1.6279.6001.124154461048929153767743874565 0 False [0]\n" ] } ], "source": [ "series_uid = '1.3.6.1.4.1.14519.5.2.1.6279.6001.124154461048929153767743874565'\n", "showCandidate(series_uid)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2020-07-26 14:43:11,085 INFO pid:9828 p2ch10.dsets:212:__init__ : 605 training samples\n" ] }, { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
');\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('