Package: usseg
Doppler SegmentationsThese codes make up the framework for segmenting the doppler ultrasound scans.Table of ContentsDoppler SegmentationsTable of ContentsInstallationUltrasound Segmentation PackageInstallationTo install as a dependency for your project:pip install ussegorpoetryaddussegDevelopment EnvironmentTo install the development environment follow the following steps.Clone this repository and change into the directory.Installpoetryas per the installation instructions.Installtesseractas per the intallation instructions.Note that the project has only been tested with tesseract version 5.Install the package dependencies with:poetry installEnter into the development shell with:poetry shellYou are now in the development environment!Copyconfig_example.tomltoconfig.tomland change the variables for your local set up (e.g. path to your data etc.).The main script can now be run in one complete run withpython usseg/main.py.If debugging in vscode, ensure the python interpreter is set to the virtual environment created poetry. This path can be found usingpoetry env info --pathUltrasound Segmentation PackageThe Ultrasound Segmentation Package facilitates two primary blocks of functionality:
text extraction from images and ultrasound image segmentation. Each block consists
of a sequence of functions designed to work independently yet contribute collectively
to the overall process.Text Extraction Processcolour_extract_vectorized: Filters the image to highlight a specific target colour of pixel, preparing it for text extraction.Text_from_greyscale: Processes the filtered image to extract text, matching lines to specific target words.Metric_check: Performs a common-sense check on the extracted measurements using knowledge of their interdependencies and known physiological limits, ensuring data accuracy.Following the successful extraction and validation of text data, the workflow transitions to the image segmentation process.Image Segmentation ProcessInitial_segmentation: Begins with a coarse segmentation of the waveform.Define_end_ROIs: Defines regions adjacent to the coarse segmentation.Segment_refinement: Refines the segmentation within the coarse boundaries.Search_for_ticks: Identifies ticks in the axes ROIs for accurate scaling.Search_for_labels: Locates labels within the axes ROIs for data extraction.Plot_Digitized_data: Digitizes the extracted data to plot the waveform.Plot_correction: (Optional) Adjusts the time axis based on heart rate data.Annotate: Visualizes the segmentation steps on the original image.Each function in these sequences plays a vital role in the overall process, which aims for accurate data extraction. For more in-depth information about each function, please refer to the detailed descriptions in theheresection of this documentation.Usage ExamplesSome introduction to examples...Processing a Single ImageFor processing a single image, thedata_from_imagefunction is imported and provided with PIL and cv2 versions of the image. This could be done through the following code:# Module importsimportnumpyasnpfromPILimportImage# Local importsfromussegimportdata_from_imageimg_path="Path/to/a/ultrasound/image.JPG"PIL_image=Image.open(img_path)cv2_image=np.array(PIL_image)df,(xdata,ydata)=data_from_image(PIL_image,cv2_image)Batch processing imagespythonusseg/main.py