In [85]:
import sys
import os
sys.path.insert(0, './src/')
from FRAPanalyzer.lifproc import LIFContainer
from FRAPanalyzer.lifproc import start_bioformats
from FRAPanalyzer.lifproc import stop_bioformats
from pprint import pprint
from collections import OrderedDict
import numpy as np
from IPython.display import HTML
In [2]:
start_bioformats()
BioContainer started
In [3]:
lif = LIFContainer('./test_data/Experiment_001.lif')
In [4]:
lif.lif_img_data
Out[4]:
OrderedDict([('Image005',
{'C': 3, 'ID': 'Image:0', 'T': 1, 'X': 512, 'Y': 512, 'Z': 1}),
('FRAP/FRAP Series09',
{'C': 2, 'ID': 'Image:1', 'T': 127, 'X': 128, 'Y': 128, 'Z': 1}),
('FRAP_004/FRAP Series16',
{'C': 1, 'ID': 'Image:2', 'T': 369, 'X': 64, 'Y': 64, 'Z': 1}),
('FRAP/FRAP Series18',
{'C': 1, 'ID': 'Image:3', 'T': 787, 'X': 64, 'Y': 64, 'Z': 1})])
In [5]:
series_id = 'FRAP_004/FRAP Series16'
In [35]:
img = lif.get_full_array(series_id, progressbar=True)
100%|██████████| 369/369 [00:26<00:00, 14.53it/s] | 1/369 [00:00<02:02, 3.01it/s]
In [7]:
img.shape
Out[7]:
(64, 64, 1, 369)
In [9]:
# img = wrp.get_full_array('FRAP_001/FRAP Series10')
# series_name = 'FRAP_001/FRAP Series10'
print(lif.lif_img_data[series_id])
current_series_id = lif.lif_series_order.index(series_id)
{'C': 1, 'T': 369, 'Y': 64, 'X': 64, 'Z': 1, 'ID': 'Image:2'}
In [8]:
from xml.etree import cElementTree as etree
xml = etree.fromstring(lif.metadata_in_xml)
In [29]:
# etree.ElementTree(xml).write("exp.xml")
In [15]:
# np.fromstring(rois[0][0][1][0].attrib['Points'])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-15-9e9f99a80e09> in <module>()
1 np.fromstring(
----> 2 rois[0][0][1][0].attrib['Points'])
ValueError: string size must be a multiple of element size
In [12]:
rois = [roi for roi in xml if roi.tag.endswith('ROI')]
rois[0][0][1][0]
vectxt = rois[0][0][1][0].attrib['Points']
float('3.57142857142857E-04')
In [10]:
stran = lif.get_structured_annotations()
In [12]:
stran[series_id]
Out[12]:
OrderedDict([('HardwareSetting',
OrderedDict([('ScannerSettingRecord',
OrderedDict([('ROI_0_Line_2_AOTF_10 #1', '0'),
('ROI_0_Line_3_AOTF_10 #1', '0'),
('ROI_0_Line_4_AOTF_10 #1', '0'),
('dblSizeY #1',
'3.84424603174603E-06'),
('nLines #1', '64.0000000000073'),
('ROI_0_Line_5_AOTF_10 #1', '0'),
('csLutName03 #1', 'Gray'),
('eSequentialMode #1', '0'),
('nDelayTime_ms #1', '38'),
('ROI_0_Line_6_AOTF_10 #1', '0'),
('eAFSubsystem #1', '0'),
('nBegin #1', '0'),
('dwLogiChMask #1', '2'),
('bIsSeriesScanAutofocusActive #1',
'0'),
('bStepSizeConstant #1', '0'),
('dblSizeZ #1', '13.984'),
('bMinimizeMode #1', '0'),
('eAFWorkflowXY #1', '2'),
('bEnableRoiScan #1', '1'),
('bStepSizerActivated #1', '1'),
('bAdaptiveFocusControlActive #1',
'0'),
('csLutName04 #1', 'Gray'),
('nPages #1', '64'),
('csScanMode #1', 'xyt'),
('dblAFCOffset #1', '-2'),
('bSecondCrystal #1', '1'),
('nEnd #1', '0'),
('eAOBSIntensityLow_World488 #1',
'0'),
('eAOBSIntensityLow_World458 #1',
'0'),
('eAFWorkflowTimelapse #1', '2'),
('eAOBSIntensityLow_World476 #1',
'0'),
('nRepeatActions #1', '1061'),
('csLutName05 #1', 'Red'),
('nAOBSConfigs #1', '8'),
('dwChannelMask #1', '4'),
('bUseVisibleShutter #1', '1'),
('dblVoxelX #1',
'6.1019778281683E-08'),
('bValidEnd #1', '0'),
('nFormatInDimension #1', '64'),
('eAOBSIntensity_World488 #1', '100'),
('eDataSource #1', '0'),
('m_bConstantIntegrationTimeActive #1',
'0'),
('eAOBSIntensity_World458 #1', '100'),
('bIsSequential #1', '0'),
('csLutName06 #1', 'Green'),
('bValidBegin #1', '0'),
('bUseMPShutter #1', '0'),
('bUseUVShutter #1', '1'),
('eAOBSIntensity_World476 #1', '100'),
('eAOBSMode_488 #1', '2'),
('eAFZUseMode #1', '1'),
('nFormatOutDimension #1', '64'),
('eAOBSMode_458 #1', '2'),
('dblVoxelY #1',
'6.10197782816831E-08'),
('eAOBSMode_476 #1', '2'),
('ROI_0_Line_0_AOTF_50 #1', '0'),
('ROI_0_Line_0_AOTF_20 #1', '1'),
('csLutName00 #1', 'Green'),
('dAdaptiveFocusControlAutonomousOffset #1',
'-2'),
('nAFWorkflowXYIterator #1', '1'),
('SystemType #1', 'TCS SP5'),
('nAccumulation #1', '1'),
('dblAFFocusRange #1', '0.00005'),
('nBit #1', '8'),
('eDirectional #1', '2'),
('bIs3DLimitedRoiScanEnable #1', '0'),
('eAFAnalyseType #1', '1'),
('nAverageLine #1', '1'),
('dblPinholeAiry #1',
'0.999752550855602'),
('csLutName01 #1', 'Cyan'),
('nAFWorkflowTimelapseIterator #1',
'1'),
('nAFPrecision #1', '2'),
('nAFFixSliceNumber #1', '11'),
('nLineAccumulation #1', '1'),
('dblPinhole #1',
'9.55023621730323E-05'),
('dblSizeX #1',
'3.84424603174603E-06'),
('dblZoom #1', '64'),
('csLutName02 #1', 'Blue'),
('nChannels #1', '1'),
('eDirectionalY #1', '1'),
('ROI_0_Line_0_AOTF_10 #1', '0'),
('nAverageFrame #1', '1'),
('eZUseMode #1', '1'),
('ROI_0_Line_1_AOTF_10 #1', '0'),
('dblZWidePos #1', '0.0061365554'),
('bAFUseFixSliceNumber #1', '0')])),
('FilterSettingRecord',
OrderedDict([('PMT NDD1 #1', 'Inactive'),
('ClassName',
'CSpectrophotometerUnit'),
('Objective #1',
'HCX PL APO CS 63.0x1.40 OIL UV'),
('Multifunction Port (MFP) #1',
'Substrate '),
('Polarization FW #1', 'Empty 1 '),
('AOBS (6) #2', '0'),
('AOBS (6) #1', '0'),
('DMI6000 Stage Pos z #1', '0'),
('MP Offset #1', '0'),
('AOBS (3) #2', '0'),
('AOBS (3) #1', '100'),
('PMT 4 #1', 'Inactive'),
('AOBS (0) #2', '0'),
('AOBS (0) #1', '100'),
('Magnification-Changer #1', 'SCANx'),
('MP Gain #1', '0'),
('Attribute', 'Stain'),
('Y Scan Actuator (Gain) #1', '64'),
('Power State #4', 'Off'),
('Power State #3', 'Off'),
('Power State #2', 'On'),
('Power State #1', 'On'),
('PMT NDD2 #1', 'Inactive'),
('Scan Field Rotation #1', '0'),
('Y Scan Actuator (Offs.) #1',
'-8.94325288307254E-04'),
('Z Scan Actuator (POS) #2',
'-2.3841880645312E-10'),
('Z Scan Actuator (POS) #1', '0'),
('Laser wavelength #4', '633'),
('Laser wavelength #3', '543'),
('Laser wavelength #2', '458'),
('Laser wavelength #1', '405'),
('AOTF (633) #2', '0'),
('AOTF (633) #1', '0'),
('X Scan Actuator #1', 'Active'),
('AOTF (488) #2', '0'),
('AOTF (488) #1', '100'),
('SMD-Phase #1', '0'),
('Dummy Name (Obj.) #1', 'Dummy4'),
('Y Scan Actuator #1', 'Active'),
('SP Mirror Channel 1 (left) #1',
'380'),
('Description',
'SP Mirror Channel 4 (stain)'),
('Y Scan Actuator (POS) #1', '0'),
('PMT Trans #1', 'Inactive'),
('DMI6000 Stage YOrigin #1', '0'),
('SP Mirror Channel 4 (left) #1',
'721.25'),
('AOTF (476) #2', '0'),
('AOTF (476) #1', '100'),
('Galvo Slider #1',
'Galvo X Normal '),
('AOBS (5) #2', '0'),
('AOBS (5) #1', '100'),
('Position #1', '3'),
('AOBS (2) #2', '0'),
('AOBS (2) #1', '100'),
('SP Mirror Channel 3 (left) #1',
'616.25'),
('Refraction index #1', '1.518'),
('Excitation FW MP #1', 'ND 3'),
('PMT 2 (HV) #1', '804'),
('AOTF (496) #2', '0'),
('AOTF (496) #1', '0'),
('SP Mirror Channel 2 (left) #1',
'500'),
('ObjectName', 'SP Mirror Channel 4'),
('SP Mirror Channel 1 (right) #1',
'432.207792207792'),
('DMI6000 Stage XOrigin #1', '0'),
('X Scan Actuator (POS) #1', '0'),
('SP Mirror Channel 2 (right) #1',
'600'),
('SP Mirror Channel 3 (right) #1',
'668.75'),
('inverse flag topo #1', '0'),
('SP Mirror Channel 4 (right) #1',
'773.75'),
('AOTF (458) #2', '0'),
('AOTF (458) #1', '100'),
('Phase #1', '-29.1309987029831'),
('Data', '0'),
('Rotation Direction #1', '1'),
('PMT 1 #1', 'Inactive'),
('PMT 2 (Offs.) #1', '0'),
('Z Scan Actuator #1', 'Inactive'),
('RLD_Settings #1', '-1'),
('Hardware Type No. #1', '7'),
('UV Lens FW #1',
'Lens 63x/1.4 Oil '),
('PMT 2 (HV_Unit) #1', 'V'),
('AOBS (7) #2', '0'),
('AOBS (7) #1', '0'),
('AOBS (4) #2', '0'),
('Reson. Galvo Pan #1',
'Galvo X Pan Center '),
('AOBS (4) #1', '100'),
('AOTF (543) #2', '0'),
('AOTF (543) #1', '0'),
('Order number (Obj.) #1',
'11506188'),
('AOBS (1) #2', '0'),
('AOBS (1) #1', '100'),
('AOTF (514) #2', '0'),
('AOTF (514) #1', '0'),
('DMI6000 Stage Pos x #1',
'0.03232095024854'),
('TLD_Settings #1', '100'),
('X Scan Actuator (Offs.) #1',
'-5.99222518125747E-05'),
('PMT 2 #1', 'Active'),
('Numerical aperture (Obj.) #1',
'1.4'),
('Y-Phase #1', '0'),
('X Scan Actuator (Gain) #1', '64'),
('VariantType', '8'),
('AOTF (405) #2', '0'),
('AOTF (405) #1', '100'),
('Scan Speed #1', '1000'),
('PMT 2 (Preamp) #1', 'Standard'),
('EOM (797) #2', '0'),
('EOM (797) #1', '0'),
('Laser output power #1',
'47.6190476190476'),
('DMI6000 Stage Pos y #1',
'0.00988457990003'),
('PMT 3 #1', 'Inactive'),
('DMI6000 Stage ZOrigin #1', '0'),
('System Number #1', '5100000830'),
('Target Slider #1',
'Target Park ')])),
('Name', 'default')])),
('Block_FRAP',
OrderedDict([('ATLConfocalSettingDefinition',
OrderedDict([('Shutter',
OrderedDict([('ShutterQualifier',
'3'),
('IsActive', '1'),
('LightSourceQualifier',
'10'),
('LightSourceName',
'Vis')])),
('LambdaExcitation',
OrderedDict([('LambdaExcitationDontMoveSPUnits',
'0'),
('LambdaLambdaMaxGapExctToDetct',
'50'),
('LambdaLambdaDetectBandWidth',
'20'),
('LambdaExcitationResolution',
'10'),
('LambdaExcitationGapToSPUnit',
'10'),
('ValidLambdaExcitationBegin',
'0'),
('LambdaLambdaMinGapExctToDetct',
'10'),
('LambdaExcitationLaserLineIndex',
'0'),
('LambdaExcitationBegin',
'465'),
('LambdaLambdaDetectStepSize',
'20'),
('ValidLambdaLambdaMaxGapExctToDetct',
'0'),
('ValidLambdaExcitationEnd',
'0'),
('LambdaExcitationSections',
'21'),
('ValidLambdaLambdaMinGapExctToDetct',
'1'),
('LambdaLambdaChannel',
'1'),
('LambdaLambdaDetectionRangeGeometry',
'0'),
('LambdaLambdaDetectEnd',
'720'),
('LambdaExcitationLightSource',
'0'),
('LambdaBandWidthSize',
'20'),
('BandWidthMode', '4'),
('LambdaLambdaDetectBegin',
'480'),
('LambdaLambdaImageCounter',
'0'),
('LambdaExcitationSPUnitMaxLambda',
'710'),
('LambdaExcitationEnd',
'700'),
('LambdaLambdaDetectNoOfSteps',
'12')])),
('IsFastZStack', '0'),
('SyncOutTriggerCycle', '1'),
('EOMComp',
OrderedDict([('OffsetMP', '0'),
('GainMP2', '0'),
('GainMP', '0'),
('CanDoMP2', '0'),
('OffsetMP2', '0'),
('CanDoMP', '0')])),
('Aotf',
OrderedDict([('Gain', '0'),
('LaserLineSetting',
OrderedDict([('AOBSIntensityLowDev',
'-1'),
('IsLineChecked',
'0'),
('IsLineDeactivated',
'0'),
('SuppressionMode',
'-1'),
('SequenceIndex',
'0'),
('EnableDoubleMode',
'0'),
('IntensityDev',
'0'),
('Qualifier',
'10'),
('LineIndex',
'6'),
('AOBSIntensityDev',
'-1'),
('LaserLine',
'633'),
('IntensityLowDev',
'0'),
('OutCheckedIntensity',
'0'),
('IsVisible',
'1')])),
('CanDoPulseFreq', '0'),
('IsChanged', '1'),
('AotfQualifier', '10'),
('TwoLaserPIEActive',
'0'),
('LightSourceQualifier',
'10'),
('PulsFreq', '0'),
('Offset', '0'),
('CanDoGainOffset',
'1'),
('OpenVirtual', '0'),
('CanDoTwoLaserPIE',
'0')])),
('OutTriggerShowInGraph', '1'),
('AotfValidEnd', '0'),
('CanDoCSMode', '1'),
('ROISet',
OrderedDict([('ROISetType', '1'),
('PossibleROITransforms',
'65535'),
('PossibleChildROITypes',
'-1'),
('PossibleROIActions',
'65535')])),
('IsUVShutterActive', '1'),
('Autofocus-config',
OrderedDict([('WorkflowTimelapse',
'2'),
('AFAnalyseType', '1'),
('WorkflowXY', '2'),
('WorkflowTimelapseIterator',
'1'),
('AFCOffset', '-2'),
('Precision', '2'),
('UseFixSliceNumber',
'0'),
('AFSubsystem', '0'),
('WorkflowXYIterator',
'1'),
('ZUseMode', '1'),
('FocusRange',
'0.00005')])),
('OutTrigger', '-1'),
('ROISingle',
OrderedDict([('Transformation',
OrderedDict([('Rotation',
'0'),
('Scaling',
OrderedDict([('YScale',
'0.894786655902863'),
('XScale',
'0.870097100734711')])),
('Translation',
OrderedDict([('Y',
'-1.43666211442905E-05'),
('X',
'9.45402803154138E-07')]))])),
('LASER_LINE',
OrderedDict([('LaserLine',
'797'),
('Qualifier',
'50'),
('LaserLineIndex',
'0'),
('Intensity',
'0')])),
('IsClosed', '1'),
('Color', '4278255416'),
('TransformationType',
'65535'),
('RoiType', '32'),
('P',
OrderedDict([('Y',
'0'),
('X',
'1.2103214430681E-06')])),
('Inverted', '0'),
('RoiAction',
'65535')])),
('IsSTEDActive', '0'),
('IsActivatedStepSizer', '1'),
('AdaptiveFocusControlAutonomousOffset',
'-2'),
('ScanSpeed', '1000'),
('Laser',
OrderedDict([('OutputPower', '0'),
('Qualifier', '10'),
('LightSourceQualifier',
'10'),
('Wavelength', '633'),
('LaserName',
'HeNe 633'),
('CanDoLinearOutputPower',
'0')])),
('Limited3DRoiLastSection', '1'),
('SyncInTriggerStartOffset', '1'),
('Quantity',
OrderedDict([('Value',
'1.17911266304116E-07')])),
('LambdaEmission',
OrderedDict([('LambdaBegin', '385'),
('BandWidth', '10'),
('IsValid', '0'),
('BandWidthMode', '0'),
('Resolution', '2.5'),
('LambdaEnd', '795'),
('Channel', '2'),
('Sections', '41')])),
('FrameTime', '0.038'),
('ObjectiveName', 'Dummy4'),
('InTriggerShowInGraph', '1'),
('ScanDirectionX', '2'),
('FrameAverage', '1'),
('IsRoiScanEnable', '1'),
('ZPosition', '-2.3841880645312E-10'),
('IsVisShutterActive', '1'),
('Detector',
OrderedDict([('Channel', '1001'),
('IsHPDDetector', '0'),
('CanDoTimeGate', '0'),
('IsFlimDetector', '0'),
('IsActive', '0'),
('IsReferenceUnitActivatedForCorrection',
'0'),
('Offset', '0'),
('Gain', '0')])),
('Magnification', '63'),
('MultiBand',
OrderedDict([('Channel', '4'),
('LeftWorld', '721.25'),
('RightWorld',
'773.75')])),
('Sections', '1'),
('LineTime', '0.0005'),
('MaxLines', '1'),
('Wheel',
OrderedDict([('FilterSpectrumPos',
'0'),
('SpectrumChanged',
'0'),
('Qualifier', '30'),
('WheelName',
OrderedDict([('FilterName',
'--- ')])),
('FilterIndex', '3'),
('LightSourceQualifier',
'40'),
('IndexChanged', '0'),
('IsSpectrumTurnMode',
'0')])),
('AdaptiveFocusControlActive', '0'),
('AotfValidBegin', '0'),
('Pages', '1'),
('LUT',
OrderedDict([('LutName', 'Green'),
('Channel', '1001')])),
('Pinhole', '9.55023621730323E-05'),
('SyncInTriggerCount', '1'),
('STEDDelayTime', '42'),
('Zoom', '64'),
('OpticalZoom', '1'),
('OutTriggerRecordInEvent', '1'),
('LastNonMP_MFP_FW_Name',
'Substrate '),
('ActiveCS_SubModeForTLD', '100'),
('ZUseMode', '1'),
('CompleteTime', '0.038'),
('BitSize', '8'),
('InTriggerRecordInEvent', '1'),
('StageRangeY', '6040599'),
('StageRangeX', '12055927'),
('LineAverage', '1'),
('STEDDelayTime2', '42'),
('FrameAccumulation', '1'),
('Is3DLimitedRoiScanEnable', '0'),
('AutoFocusMode', '2'),
('IsAutofocusOnStart', '0'),
('IsSuperZ', '0'),
('CanDoOpticalZoom', '0'),
('CycleCount', '1'),
('IsSMDChaserUVAOTFAutomationActive',
'0'),
('PhaseX', '23222'),
('IsFCSFilterAutomationActive', '0'),
('PanFirstDim',
'-5.99222518125747E-05'),
('ValidBeginStack', '0'),
('InTrigger', '-1'),
('AdditionalZPosition',
OrderedDict([('SuperZMode', '1'),
('Valid', '1'),
('ZPosition',
'0.0061365554'),
('ZMode', '2')])),
('Memory',
OrderedDict([('Size', '0'),
('MemoryBlockID',
'MemBlock_48')])),
('UseMaxIterationsForT', '0'),
('SyncInTriggerCycle', '1'),
('AutofocusRedoEveryNTimePoints',
'0'),
('ScanMode', 'xyt'),
('AutofocusChannel', '1'),
('ActiveCS_SubModeForRLD', '-1'),
('SyncOutTriggerStartOffset', '1'),
('PinholeAiry', '0.999752550855602'),
('AdaptiveFocusControlAutonomousModeActive',
'0'),
('Line_Accumulation', '1'),
('IsMPShutterActive', '0'),
('UserSettingName', 'S6'),
('VersionNumber', '3'),
('SyncOutTriggerPulseEndLine', '1'),
('Lines', '512'),
('DetectorValidBegin', '0'),
('SyncOutTriggerPulsCount', '1'),
('IsTimeMinimizeEnabled', '0'),
('OutDimension', '64'),
('InDimension', '64'),
('LambdaExcitationMode', '0'),
('Limited3DRoiFirstSection', '1'),
('ObjectivePos', '3'),
('PanSecondDim',
'-8.94325288307254E-04'),
('SyncOutTriggerPulseStartLine', '0'),
('ZStackDirectionMode', '1'),
('StagePosZ', '0'),
('StagePosY', '2024363'),
('StagePosX', '6619334'),
('ObjectiveNumber', '11506188'),
('RotatorAngle', '0'),
('StepSizeConstant', '0'),
('LastNonMP_Pol_FW_Name', 'Empty 1 '),
('ValidEndStack', '0'),
('IsUserSettingNameSet', '0'),
('ZIntensityCompensationMode', '0'),
('LastTCalcMode', '3'),
('CycleTime', '0.648'),
('DetectorValidEnd', '0')])),
('ROIDATA',
OrderedDict([('Rotation',
OrderedDict([('Y', '0'),
('X', '0')])),
('Size',
OrderedDict([('Y',
'2.13809838277215E-06'),
('X',
'2.10619435714121E-06')])),
('Name', 'ROI1'),
('Type', 'CIRCLE'),
('Colour', '16777215'),
('Position',
OrderedDict([('Y',
'-1.43666211442905E-05'),
('X',
'-9.45402803154138E-07')]))])),
('LaserLineSetting',
OrderedDict([('IsChecked', '0'),
('IntensityDev', '0'),
('IsVisible', '1'),
('IntensityLowDev', '0'),
('EnableDoubleMode', '0'),
('SequenceIndex', '0'),
('Qualifier', '10'),
('LineIndex', '6'),
('AOBSIntensityLowDev', '-1'),
('LaserLine', '633'),
('SuppressionMode', '-1'),
('AOBSIntensityDev', '-1')])),
('LASER_LINE',
OrderedDict([('LaserLine', '633'),
('Intensity', '0'),
('LaserLineIndex', '8'),
('Qualifier', '10')])),
('Block_FRAP_Time_Info',
OrderedDict([('Time', '0.038'),
('FrameCount', '1000'),
('IsMinimized', '1')])),
('IsBleachChaserVisShutterActive', '0'),
('IsBleachUV405ShutterActive', '0'),
('IsBleachMP2ShutterActive', '0'),
('IsBleachMPShutterActive', '0'),
('IsBleachPulsed635ShutterActive', '0'),
('IsFlyModeEnabled', '0'),
('IsBleachSuperContVisShutterActive', '0'),
('IsBleachVisShutterActive', '1'),
('IsBleachUVShutterActive', '1'),
('IsBleachChaserUVShutterActive', '0'),
('UseBleachMode', '0'),
('IsSetBackGrd1ChnToZero', '1'),
('IsChangeFormatEnabled', '0'),
('IsZoomInEnabled', '0')])),
('ChannelScalingInfo',
OrderedDict([('BlackValue', '0'),
('GammaValue', '1'),
('WhiteValue', '1'),
('Automatic', '0')])),
('DimensionDescription',
OrderedDict([('BytesInc', '4096'),
('DimID', '4'),
('NumberOfElements', '369'),
('Origin', '0.000000e+000'),
('BitInc', '0'),
('Unit', 's'),
('Length', '1.402900e+001')])),
('ChannelDescription',
OrderedDict([('LUTName', 'Cyan'),
('IsLUTInverted', '0'),
('BytesInc', '0'),
('BitInc', '0'),
('Resolution', '8'),
('Min', '0.000000e+000'),
('Max', '2.550000e+002'),
('ChannelTag', '0'),
('DataType', '0')])),
('Reverse Y orientation', 'true'),
('Quantity', OrderedDict([('Value', '0'), ('Unit', 'V')])),
('Reverse X orientation', 'false'),
('Image name', 'FRAP_004/FRAP Series16')])
In [13]:
rois_struc = lif.get_rois_from_oemxml()
In [14]:
poly = rois_struc['ROI:0'][1]['Polygon']
In [15]:
%matplotlib notebook
import matplotlib.pyplot as plt
/usr/local/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
In [36]:
img = img[:,:,0,:100]
In [37]:
img.shape
Out[37]:
(64, 64, 100)
In [54]:
# prebleach 0-1, bleach 1 - 60 , after-bleach 61 -
t = 60
fig = plt.figure()
plt.imshow(img[:,:,t])
x0, y0 = 32.0, 28.5
R = 17
t = np.linspace(0, np.pi * 2, 100)
x = x0 + R*np.sin(t)
y = y0 + R*np.cos(t)
plt.plot(x,y,color='w', linewidth=2.0)
Out[54]:
[<matplotlib.lines.Line2D at 0x131c40f10>]
In [55]:
from skimage.filters import (sobel_h, sobel_v)
In [58]:
sh_frames = np.zeros(img.shape[:2] + (39,))
sv_frames = np.zeros(img.shape[:2] + (39,))
In [59]:
for i in range(61,100):
sh_frames[:,:,i-61] = sobel_h(img[:,:,i])
sv_frames[:,:,i-61] = sobel_v(img[:,:,i])
In [65]:
np.convolve?
In [66]:
def win_average(arr, n=3):
length = arr.shape[-1]
result = np.zeros(arr.shape[:2] + (length - n + 1,))
for i in range(length - n + 1):
result[:,:,i] = arr[:,:,i:i+n].sum(axis=2)/n
return result
In [73]:
sh_avg = win_average(sh_frames, n=5)
sv_avg = win_average(sv_frames, n=5)
In [87]:
import matplotlib.pyplot as plt
from matplotlib import animation
In [94]:
# fig = plt.figure()
fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.set_title('Horizontal filter')
ax2.set_title('Vertical filter')
h1 = ax1.imshow(sh_avg[:,:,0], cmap=plt.cm.jet)
h2 = ax2.imshow(sv_avg[:,:,0], cmap=plt.cm.jet)
ax1.plot(x,y,color='w', linewidth=2.0)
ax2.plot(x,y,color='w', linewidth=2.0)
def init():
h1.set_data(np.zeros_like(sh_avg[:,:,0]))
h2.set_data(np.zeros_like(sv_avg[:,:,0]))
return h1, h2
def animate(i):
h1.set_data(sh_avg[:,:,i])
h2.set_data(sv_avg[:,:,i])
return h1, h2
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=sv_avg.shape[-1])#, interval=20, blit=True)
# anim.save('basic_animation_sobel.mp4', fps=30, extra_args=['-vcodec', 'libx264'])
In [93]:
X, Y = np.meshgrid(np.arange(0, 2 * np.pi, .2), np.arange(0, 2 * np.pi, .2))
U = np.cos(X)
V = np.sin(Y)
# 1
plt.figure()
Q = plt.quiver(U, V)
qk = plt.quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W',
fontproperties={'weight': 'bold'})
l, r, b, t = plt.axis()
dx, dy = r - l, t - b
plt.axis([l - 0.05*dx, r + 0.05*dx, b - 0.05*dy, t + 0.05*dy])
plt.title('Minimal arguments, no kwargs')
Out[93]:
<matplotlib.text.Text at 0x136770150>
In [92]:
# 2
plt.figure()
Q = plt.quiver(X, Y, U, V, units='width')
qk = plt.quiverkey(Q, 0.9, 0.95, 2, r'$2 \frac{m}{s}$',
labelpos='E',
coordinates='figure',
fontproperties={'weight': 'bold'})
plt.axis([-1, 7, -1, 7])
plt.title('scales with plot width, not view')
# 3
plt.figure()
Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
pivot='mid', color='r', units='inches')
qk = plt.quiverkey(Q, 0.5, 0.03, 1, r'$1 \frac{m}{s}$',
fontproperties={'weight': 'bold'})
plt.plot(X[::3, ::3], Y[::3, ::3], 'k.')
plt.axis([-1, 7, -1, 7])
plt.title("pivot='mid'; every third arrow; units='inches'")
# 4
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-92-3154d1bda96f> in <module>()
1 # 2
2 plt.figure()
----> 3 Q = plt.quiver(X, Y, U, V, units='width')
4 qk = plt.quiverkey(Q, 0.9, 0.95, 2, r'$2 \frac{m}{s}$',
5 labelpos='E',
NameError: name 'X' is not defined
In [ ]:
In [91]:
img.shape
Out[91]:
(64, 64, 100)
In [95]:
from matplotlib import pyplot as plt
from matplotlib import animation
fig = plt.figure()
ax = plt.imshow(img[:,:,0])
def init():
ax.set_data(np.zeros_like(img[:,:,0]))
return ax,
def animate(i):
# print(i)
ax.set_data(img[:,:,i])
# edge_roberts = roberts(image)
# ax.set_data(roberts(img[:,:,channel,i]))
return ax,
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=img.shape[-1])#, interval=20, blit=True)
# anim.save('basic_animation_dafg.mp4', fps=30, extra_args=['-vcodec', 'libx264'])
In [50]:
HTML(anim.to_html5_video())
Out[50]: