You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following examples demonstrate a variant of the well-known Nyul histogram standardization algorithm that permits masking and uses a B-spline approximation technique for histogram fitting. For the ITK implementation, use histogram_matching(...) in ANTsPy or histogramMatching(...) in ANTsR.
>>>importants>>>importantspynet>>>>>>t1=ants.image_read(antspynet.get_antsxnet_data('mprage_hippmapp3r'))
>>>kk=antspynet.cortical_thickness(t1, verbose=True)
>>>ants.plot(t1, overlay=kk['thickness_image'], overlay_alpha=0.75)
>>>>>># Also see antspynet.longitudinal_cortical_thickness(...)
>>>importants>>>importantspynet>>>>>>t1=ants.image_read(antspynet.get_antsxnet_data("mprage_hippmapp3r"))
>>>>>># Computing the thickness image will take relatively more time than the other >>># outputs so the recommendation would be to run it initially without computing the >>># thickness image to just get a sense of the application. >>>>>>cereb=antspynet.cerebellum_morphology(t1, compute_thickness_image=True, verbose=True)
>>>>>># possible refinement with cerebellum estimate (comment out since it's not needed for this image). >>># mask = ants.threshold_image(cereb['cerebellum_probability_image'], 0.5, 1, 1, 0) >>># cereb = antspynet.cerebellum_morphology(t1, cerebellum_mask=mask, verbose=True) >>>>>>ants.image_write(cereb['cerebellum_probability_image'], "cerebellum_probability_mask.nii.gz")
>>>ants.image_write(cereb['thickness_image'], "kk.nii.gz")
>>>ants.image_write(cereb['parcellation_segmentation_image'], "parcelation.nii.gz")
R
> library( ANTsR )
> library( ANTsRNet )
>>t1<- antsImageRead( getANTsXNetData( "mprage_hippmapp3r" ) )
>># Computing the thickness image will take relatively more time than the other ># outputs so the recommendation would be to run it initially without computing the ># thickness image to just get a sense of the application. >cereb<- cerebellumMorphology( t1, computeThicknessImage=TRUE, verbose=TRUE )
>># possible refinement with cerebellum estimate (comment out since it's not needed for this image). ># mask <- thresholdImage( cereb$cerebellumProbabilityImage, 0.5, 1, 1, 0 ) ># cereb <- cerebellumMorphology( t1, cerebellumMask = mask, verbose = TRUE ) >># Write output to disk > antsImageWrite( cereb$cerebellumProbabilityImage, "cerebellumProbabilityMask.nii.gz" )
> antsImageWrite( cereb$tissueSegmentationImage, "tissue.nii.gz" )
> antsImageWrite( cereb$thicknessImage, "kk.nii.gz" )
> antsImageWrite( cereb$parcellationSegmentationImage, "parcelation.nii.gz" )
>>>importants>>>importantspynet>>>importtensorflowastf>>>>>># Process the proton image to get the lung mask>>>proton_file=tf.keras.utils.get_file(fname="protonLung.nii.gz", origin="https://figshare.com/ndownloader/files/42934228", force_download=True)
>>>proton=ants.image_read(proton_file)
>>>lung_ex=antspynet.lung_extraction(proton, modality="proton", verbose=True)
>>>lung_mask=ants.threshold_image(lung_ex['segmentation_image'], 0, 0, 0, 1 )
>>>>>># Use 'el bicho' to label the four ventilation levels>>>ventilation_file=tf.keras.utils.get_file(fname="ventilationLung.nii.gz", origin="https://figshare.com/ndownloader/files/42934231", force_download=True)
>>>ventilation=ants.image_read(ventilation_file)
>>>eb=antspynet.el_bicho(ventilation, lung_mask, verbose=True)
>>>ants.plot(ants.iMath_normalize(ventilation), eb['segmentation_image'], alpha=0.5)
R
> library( ANTsR )
> library( ANTsRNet )
>># Process the proton image to get the lung mask>protonFile<-tensorflow::tf$keras$utils$get_file( fname="protonLung.nii.gz", origin="https://figshare.com/ndownloader/files/42934228", force_download=TRUE )
>proton<- antsImageRead( protonFile )
>lungEx<- lungExtraction( proton, modality="proton", verbose=TRUE )
>lungMask<- thresholdImage( lungEx$segmentationImage, 0, 0, 0, 1 )
>># Use 'el bicho' to label the four ventilation levels>ventilationFile<-tensorflow::tf$keras$utils$get_file( fname="ventilationLung.nii.gz", origin="https://figshare.com/ndownloader/files/42934231", force_download=TRUE )
>ventilation<- antsImageRead( ventilationFile )
>eb<- elBicho( ventilation, lungMask, verbose=TRUE )
> plot( ventilation, eb$segmentationImage, alpha=0.5 )
>>>importants>>>importantspynet>>>importdeepsimlr>>>>>># This particular subject is diagnosed as having cardiomegaly >>>cxr_file=tf.keras.utils.get_file(fname="cxr.nii.gz", origin="https://figshare.com/ndownloader/files/42429156", force_download=True)
>>>cxr=ants.image_read(cxr_file)
>>>>>># Pytorch version adapted from https://github.com/jrzech/reproduce-chexnet>>>deepsimlr.chexnet(cxr)
AtelectasisCardiomegalyEffusionInfiltrationMassNodulePneumoniaPneumothoraxConsolidationEdemaEmphysemaFibrosisPleural_ThickeningHernia00.0272590.7453550.0424210.0492250.0036130.0260830.0059460.0030070.0050990.0020630.0172970.0599560.043540.004266>>>>>># Keras implementation in ANTsXNet (original)>>>antspynet.chexnet(cxr, use_antsxnet_variant=False)
AtelectasisCardiomegalyEffusionInfiltrationMassNodulePneumoniaPneumothoraxConsolidationEdemaEmphysemaFibrosisPleural_ThickeningHernia00.1332840.645780.0854620.094860.0194050.0189750.0130670.0210750.0280010.0058510.0189550.05550.0342190.00972>>>>>># Keras implementation in ANTsXNet (variation)>>>antspynet.chexnet(cxr, use_antsxnet_variant=True, include_tuberculosis_diagnosis=True)
AtelectasisCardiomegalyEffusionInfiltrationMassNodulePneumoniaPneumothoraxConsolidationEdemaEmphysemaFibrosisPleural_ThickeningHerniaTuberculosis00.0696230.8985340.0395890.0557510.0059310.0303090.0068760.0139990.0106210.0056770.0488580.0216680.0138670.0085460.000285
R
> library( ANTsR )
> library( ANTsRNet )
>>cxrFile<-tensorflow::tf$keras$utils$get_file( fname="cxr.nii.gz", origin="https://figshare.com/ndownloader/files/42429156", force_download=TRUE )
>cxr<- antsImageRead( cxrFile )
>># Keras implementation in ANTsXNet (original)> chexnet( cxr, useANTsXNetVariant=FALSE )
AtelectasisCardiomegalyEffusionInfiltrationMassNodule10.10652750.70389190.092046690.10067640.029438370.02722431PneumoniaPneumothoraxConsolidationEdemaEmphysemaFibrosis10.012930340.019175280.029440430.0067279490.015332130.06293546Pleural_ThickeningHernia10.033416140.01022097>># Keras implementation in ANTsXNet (variation)> chexnet( cxr, useANTsXNetVariant=TRUE, includeTuberculosisDiagnosis=TRUE )
AtelectasisCardiomegalyEffusionInfiltrationMassNodule10.074437990.96607690.11685890.087526310.010589790.03241358PneumoniaPneumothoraxConsolidationEdemaEmphysemaFibrosis10.012114020.020423380.016151810.013467250.0522930.0357863Pleural_ThickeningHerniaTuberculosis10.02352170.0089288990.0002852035>