<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Stefan Lehman on Medium]]></title>
        <description><![CDATA[Stories by Stefan Lehman on Medium]]></description>
        <link>https://medium.com/@stefanlehman2?source=rss-fc848fe6f5f7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QvfZubA_tJOyl1-g3VK2tw.jpeg</url>
            <title>Stories by Stefan Lehman on Medium</title>
            <link>https://medium.com/@stefanlehman2?source=rss-fc848fe6f5f7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 19:17:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stefanlehman2/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Revolutionizing Radiology: Integrating Machine Learning Models for Enhanced Brain Tumor Diagnosis]]></title>
            <link>https://medium.com/@stefanlehman2/revolutionizing-radiology-integrating-machine-learning-models-for-enhanced-brain-tumor-diagnosis-f427e6980f79?source=rss-fc848fe6f5f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f427e6980f79</guid>
            <category><![CDATA[gemini-pro-vision]]></category>
            <category><![CDATA[openai-whis]]></category>
            <category><![CDATA[medicine]]></category>
            <category><![CDATA[radiology]]></category>
            <dc:creator><![CDATA[Stefan Lehman]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 04:05:03 GMT</pubDate>
            <atom:updated>2024-02-22T16:00:05.908Z</atom:updated>
            <content:encoded><![CDATA[<p>By Stefan Lehman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*R-UqkRaw1WtlQRrGMcACwA.jpeg" /><figcaption>MRI from Kaggle’s Brain Tumor MRI Dataset — “data/glioma/Te-gl_0177.jpg”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*3FmfCSKxSfbhbuaW2d4nrg.jpeg" /><figcaption>MRI from Kaggle’s Brain Tumor MRI Dataset — “data/glioma/Te-gl_0138.jpg”</figcaption></figure><p>Github: <a href="https://github.com/tinytimor/gemini_mris">https://github.com/tinytimor/gemini_mris</a></p><p>In the rapidly evolving field of medical diagnostics, the integration of artificial intelligence (AI) technologies offers unprecedented opportunities for enhancing accuracy, efficiency, and patient care. The proof of concept I developed, which combines the capabilities of Python with LangChain, Google’s Gemini Pro Vision, and OpenAI’s Whisper, stands at the forefront of this innovation, specifically targeting the detection and reporting of brain tumors through MRI scan analysis.</p><h3>Need in Radiology</h3><p>Medical diagnostics is an area where precision and speed can save lives, especially in detecting and treating brain tumors. Traditional diagnostic processes can be time-consuming and rely heavily on the expertise of radiologists, who meticulously analyze MRI scans to identify the presence and characteristics of tumors. With the increasing volume of diagnostic scans and the global shortage of skilled radiologists, there’s a pressing need for supportive tools that can automate parts of the diagnostic process, reduce analysis time, and assist in prioritizing urgent cases (<a href="https://radiologybusiness.com/topics/healthcare-management/healthcare-staffing/mismatch-between-radiologist-shortages-rising-exam-volumes-growing-concern-medical-imaging">Radiology Business</a>).</p><h3>Leveraging a Rich MRI Dataset</h3><p>The cornerstone of developing any AI-based tool is a strong and reliable dataset. For this project, I used a comprehensive dataset of MRI scans sourced from <a href="https://www.kaggle.com/datasets/masoudnickparvar/brain-tumor-mri-dataset">Kaggle</a>, specifically designed for the detection of brain tumors. This dataset includes a variety of MRI images, meticulously labeled based on the presence of brain tumors, providing a robust dataset for training machine learning models to recognize and analyze brain tumor characteristics accurately.</p><h3>The Technology Stack: Python, LangChain, Google’s Gemini Pro Vision Model, and OpenAI’s Whisper Model</h3><h3>Python and LangChain: The Backbone of Our Solution</h3><p>Python serves as the backbone of the project, facilitating data manipulation, model integration, and the orchestration of the entire diagnostic pipeline. <a href="https://python.langchain.com/docs/get_started/introduction">LangChain</a>, a library for chaining Large Language Models (LLMs) to perform complex tasks, allows us to seamlessly integrate different models and services into a cohesive workflow.</p><h3>Gemini Pro Vision: Elevating Image Analysis</h3><p>Google’s Gemini Pro Vision, an advanced multimodal model, is employed to process the MRI images. By feeding these images into Gemini Pro Vision through LangChain, we can generate detailed medical reports that describe the scans’ findings. This step not only aids radiologists in creating preliminary reports but also streamlines the workflow by automating the initial analysis of MRI images.</p><pre>from PIL import Image<br>from IPython.display import Image, display<br><br># Displaying MRI in Jupyter Notebook<br>display(Image(image_ls[&quot;data/glioma/Te-gl_001.jpg&quot;]))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*uXs1y-Tcpt54vWcxM74gBw.jpeg" /><figcaption>Input MRI for Google’s Gemini Pro Vision— Path: “data/glioma/Te-gl_0014.jpg”</figcaption></figure><pre>import os<br>from langchain.prompts import PromptTemplate<br>import google.generativeai as genai<br>from langchain_google_genai import ChatGoogleGenerativeAI<br>from langchain_core.messages import HumanMessage<br><br># Setting up an environment variable for Google API key<br>os.environ[&quot;GOOGLE_API_KEY&quot;] = &quot;&quot;<br><br># Define MRI path<br>image_url = &quot;data/glioma/Te-gl_0014.jpg&quot;<br><br># Initialize the ChatGoogleGenerativeAI model with a specified model<br>llm = ChatGoogleGenerativeAI(model=&quot;gemini-pro-vision&quot;)<br><br># Creating a message object with content to prompt the LLM to help analyze <br># and generate reports for Radiologists<br>message = HumanMessage(<br>        content=[<br>            {<br>                &quot;type&quot;: &quot;text&quot;,<br>                &quot;text&quot;: &quot;&quot;&quot;You are tasked to help Radiologists and other <br>doctors create a report of these x-ray images comprising of T2 MRI images. <br>Describe the following image: {image_url} to create a medical report for <br>each file name with a tag. &quot;&quot;&quot;,<br>            },<br>            {&quot;type&quot;: &quot;image_url&quot;, &quot;image_url&quot;: image_url},<br>        ]<br>    )<br><br># Invoking the model with the message<br>response = llm.invoke([message])<br>print(response.content)</pre><pre>Gemini Pro Vision&#39;s Output: <br><br>**Patient Name:** John Doe<br>**Age:** 55<br>**Sex:** Male<br><br>**History:** The patient is a 55-year-old male with a history of hypertension <br>and diabetes. He presents with a 2-week history of headaches and nausea.<br><br>**Imaging Findings:** The MRI scan shows a large, round mass in the right <br>frontal lobe of the brain. The mass is hypointense on T1-weighted images <br>and hyperintense on T2-weighted images. There is surrounding edema and <br>mass effect.<br><br>**Diagnosis:** Brain tumor, likely glioma<br><br>**Treatment:** The patient will undergo surgery to remove the tumor.<br><br>**Prognosis:** The prognosis for this patient depends on the type of brain <br>tumor and the extent of the surgery.</pre><p>Text to Video Generation from <a href="https://runwayml.com/">Runaway AI</a>:</p><p><a href="https://youtube.com/shorts/JtzCkPuY9-E">https://youtube.com/shorts/5FhbysJie_w?si=QPYCyo2f6joeV1nb</a></p><h3>OpenAI Whisper: Transforming Text into Speech</h3><p>To further enhance the usability of the generated reports, I incorporated OpenAI’s Whisper, a sophisticated text-to-speech model. Once Gemini Pro Vision generates the medical reports, Whisper converts these reports into audio files. The proof of concept explores the opportunity to provide radiologists and medical professionals with the flexibility to listen to the reports on the go, provide recordings for the patient, and archiving radiological reports, facilitating a better understanding of the diagnostic findings and recommendations.</p><pre>import json<br>import langchain<br>from openai import OpenAI<br><br><br>response = &quot;&quot;&quot;**Patient Name:** John Doe<br>**Age:** 55<br>**Sex:** Male<br><br>**History:** The patient is a 55-year-old male with a history of hypertension <br>and diabetes. He presents with a 2-week history of headaches and nausea.<br><br>**Imaging Findings:** The MRI scan shows a large, round mass in the right <br>frontal lobe of the brain. The mass is hypointense on T1-weighted images <br>and hyperintense on T2-weighted images. There is surrounding edema and <br>mass effect.<br><br>**Diagnosis:** Brain tumor, likely glioma<br><br>**Treatment:** The patient will undergo surgery to remove the tumor.<br><br>**Prognosis:** The prognosis for this patient depends on the type of <br>brain tumor and the extent of the surgery.&quot;&quot;&quot;<br><br># Initialize the OpenAI client with your API key<br>client = OpenAI(api_key = &quot;&quot;)<br><br># Create an audio file from the text contained in `response` using the <br># text-to-speech service<br>audio = client.audio.speech.create(<br>    model = &#39;tts-1&#39;,  <br>    voice = &#39;onyx&#39;,   # Specifies the voice model for the audio output<br>    input = response  # The text input that will be converted to speech<br>)<br><br># Save the generated audio to a file named &#39;radiology_report.mp3&#39; in the<br># current working directory.<br>audio.write_to_file(&#39;radiology_report.mp3&#39;)</pre><p>Audio Generation of Radiology Report Generated from OpenAI’s Whisper:</p><p><a href="https://github.com/tinytimor/gemini_mris/assets/108763451/f03cab29-2ce4-4d75-9dde-f6d003938a5f">https://github.com/tinytimor/gemini_mris/assets/108763451/f03cab29-2ce4-4d75-9dde-f6d003938a5f</a></p><h3>Impact and Future Directions</h3><p>The integration of Gemini Pro Vision and OpenAI’s Whisper into the diagnostic process offers several key benefits:</p><ul><li><strong>Efficiency and Time-Saving</strong>: Automates the initial analysis of MRI scans, significantly reducing the time required for radiologists to generate reports.</li><li><strong>Enhanced Accuracy</strong>: AI models can consistently analyze scans, reducing the risk of human error and improving diagnostic accuracy.</li><li><strong>Accessibility and Learning</strong>: Audio reports generated by Whisper can serve as valuable learning tools for medical students and professionals, enhancing their understanding of radiological terminology and diagnostic processes.</li></ul><p>Looking ahead, the potential applications of AI in medical diagnostics are vast. Future work could explore the integration of additional AI models for even more detailed analyses, the development of AI tools for other types of medical imaging, and the expansion of the dataset to include more varied and complex cases.</p><h3>Limitations</h3><ol><li>Bias in Algorithms: AI models can inherit biases present in the training data, potentially leading to skewed or unfair outcomes for certain patient groups. This bias can manifest in various forms, such as demographic biases (related to age, gender, ethnicity, etc.) or disease-specific biases.</li><li>Over-reliance on AI: There’s a risk that clinicians might become over-reliant on AI, potentially overlooking its limitations or misinterpreting its findings.</li><li>Confirmational Bias: AI-generated reports might lead to confirmation bias, where radiologists might give undue weight to AI findings, potentially overlooking alternative diagnoses (<a href="https://www.v7labs.com/blog/ai-in-radiology">v7Labs</a>).</li><li>Accuracy and Reliability: While AI can significantly enhance the accuracy of diagnoses, errors and inaccuracies can still occur, especially in complex cases or when the AI encounters rare conditions not well-represented in its training data.</li><li>Data Privacy and Security: The use of AI in analyzing MRIs involves handling sensitive patient data, raising concerns about data privacy and security.</li><li>Regulatory and Ethical Considerations: The integration of AI into healthcare raises regulatory and ethical questions, including liability in case of misdiagnoses and ensuring patient consent for the use of their data in AI training (<a href="https://journals.library.columbia.edu/index.php/bioethics/article/view/8662">Columbia University</a>).</li></ol><p>For the successful integration of AI in radiology, stakeholders must engage in early and deliberate actions to address ethical and practical challenges. This involves:</p><ul><li>Data Diversity: Using broad, representative datasets to train AI, reducing biases.</li><li>Continuous Monitoring: Regularly evaluating AI models for biases to ensure fairness and accuracy.</li><li>Human Oversight: Incorporating radiologists in the validation process of AI-generated findings to catch and correct biases.</li><li>Regulatory Compliance: Implementing stringent regulatory standards and ethical guidelines for AI development and usage in healthcare.</li><li>Patient Communication: Maintaining transparency with patients regarding the use of their data, enhancing trust and understanding.</li></ul><h3>Considerations</h3><p>While this proof of concept showcases the potential of multimodal machine learning models, it’s important to recognize that these tools serve as accelerators for medical professionals rather than replacements. Their primary aim is to alleviate the burden of administrative tasks and red tape, allowing professionals to dedicate more time to patient care. For instance, studies consistently show that physicians spend double the amount of time on electronic documentation and clerical duties compared to direct patient care (<a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8068426/">NIH</a>).</p><p>Considering risks that may be introduced using these tools, developers and implementers need to have thought out plans for managing concerns from users and governments about bad actors. Prompt moderation is crucial to ensure these systems do not pose a risk to the users nor their harmful outputs (<a href="https://platform.openai.com/docs/guides/safety-best-practices">OpenAI</a>). Additionally, these solutions and tools need to comply with HIPAA and other data privacy laws in the US (<a href="https://www.hhs.gov/hipaa/for-professionals/privacy/laws-regulations/index.html">HHS</a>). Processes such as data de-identification and the utilization of these models within secure, air-gapped environments within healthcare systems are paramount to safeguard patient privacy and cybersecurity.</p><p>When developing these solutions, engineers, researchers, and clinicians need to proactively address concerns ias can be mitigated by using diverse and representative datasets for training and regularly testing the AI models for bias. Involvement of a human in the loop, such as a radiologist, can help identify and correct biases in AI-generated reports. Clear regulatory frameworks and guidelines for the development and use of AI in healthcare, along with transparent communication with patients about how their data is used, are essential.</p><h3>Conclusion</h3><p>By developing this pipeline in Python with LangChain, Gemini Pro Vision, and Whisper, this project not only demonstrates the feasibility of AI-assisted tools in radiology but also sets the stage for future innovations in the field. As we continue to refine and expand these tools, the goal of enhancing patient care through technology becomes increasingly attainable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f427e6980f79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Large Language Models and LangChain]]></title>
            <link>https://medium.com/@stefanlehman2/introduction-to-large-language-models-and-langchain-5ce23ca8d9a0?source=rss-fc848fe6f5f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ce23ca8d9a0</guid>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Stefan Lehman]]></dc:creator>
            <pubDate>Fri, 08 Dec 2023 23:22:15 GMT</pubDate>
            <atom:updated>2023-12-08T23:22:15.583Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n6w9MRB7tR8x6rmL6dKpBg.png" /></figure><p><strong>Overview of AI and Large Language Models (LLMs)</strong></p><p><strong>AI (Artificial Intelligence) Models</strong> encompass a broad range of algorithms and technologies that simulate human intelligence. They can include everything from machine learning models, neural networks, to decision trees, and are designed for tasks like image recognition, decision making, and pattern detection.</p><p><strong>Large Language Models (LLMs)</strong>, a subset of AI models, are specifically trained on vast amounts of text data. These models, such as GPT (Generative Pre-trained Transformer) from OpenAI, excel in understanding and generating human-like text. They are adept at tasks like language translation, content creation, and answering questions.</p><p><strong>LangChain: Bridging LLMs with Real-World Applications</strong></p><p><strong>LangChain</strong> is an innovative yet simplistic framework that integrates advanced LLMs into practical applications. In other words, it allows users to use complex AI capabilities with minimal amounts of code, enabling the users to tailor LLMs for their specific applications. It supports various models (like those from OpenAI, Cohere, Hugging Face, Google, and Anthropic), simplifying the application of AI in real-world scenarios. It serves as a versatile platform, translating complex AI capabilities into accessible tools for a variety of applications.</p><p><em>Why use LangChain?</em></p><p>The framework is designed to be model-agnostic, meaning it can work with a variety of AI models, providing a flexible platform for developing AI-powered applications. LangChain achieves this by abstracting the complexities of LLMs models, making it easier for developers to implement and leverage these technologies without needing in-depth knowledge of the underlying mechanics of these models.</p><p><strong>Key Features:</strong></p><ul><li>Model-Agnostic: Compatible with models from OpenAI, Cohere, Hugging Face, etc.</li><li>User-Friendly: Simplifies complex AI model applications.</li><li>Versatile: Suitable for diverse AI-driven projects.</li></ul><p>Example of instantiating a model in Python:</p><pre># Basic LangChain integration with an LLM<br>from langchain.chat_models import ChatOpenAI<br><br># Enter your OpenAI Key<br>openai_api_key = &#39;sk-…..&#39; # replace the contents within the string with your key<br><br># Initialize Langchain with an OpenAI model<br>llm = ChatOpenAI(temperature=0, openai_api_key= openai_api_key, model=&quot;gpt-4&quot;)</pre><p>Reference: <a href="http://hain.com/docs/get_started/introduction">LangChain Introduction</a>, <a href="https://python.langchain.com/docs/get_started/quickstart">LangChain Quickstart</a></p><p><strong>Prompt Engineering in LangChain</strong></p><p><strong>Prompt engineering</strong> is a critical aspect of working with large language models (LLMs), like OpenAI’s GPT series. It involves the strategic design of input prompts to produce the most effective and relevant outputs from the model. Here are key aspects and considerations in prompt engineering:</p><p><strong>Definition and Objectives</strong></p><ul><li>Crafting Prompts: A well-engineered prompt leads to more accurate, relevant, and contextually appropriate responses from an LLM. The goal is to “nudge” the model into a specific mode of response that aligns with the user’s intent.</li><li>Directing Model Behavior: By carefully choosing language, structure, and information in the prompt, you can guide the model to perform tasks such as answering questions, generating text, or providing explanations.</li></ul><p><strong>Importance in LLM Interactions</strong></p><ul><li>Effectiveness: The quality of a prompt can significantly influence the performance of an LLM. Effective prompts result in responses that require less post-processing and are more aligned with the user’s expectations.</li><li>Efficiency: Good prompts can reduce the computational cost by obtaining the desired output in fewer iterations, which is crucial for applications where response time is critical.</li></ul><p><strong>Uses in Applications</strong></p><ul><li>Chatbots: In customer service or interactive applications, prompt engineering can dictate how well a chatbot understands and responds to user queries.</li><li>Content Generation: For creative writing, marketing, or coding, engineered prompts can help generate more relevant and innovative content.</li><li>Data Analysis: When extracting information from large datasets, the way questions are phrased can determine the quality of insights gleaned from an LLM.</li></ul><p><strong>Techniques in Prompt Engineering</strong></p><ul><li>Template-Based: Using a set structure for prompts that can be dynamically filled with different variables depending on the context.</li><li>Few-Shot Learning: Providing the model with a few examples within the prompt to illustrate the task at hand, helping it to understand and generalize from these examples to the current request.</li><li>Chain-of-Thought Prompting: Including a series of logical steps within the prompt to lead the model through a more detailed reasoning process.</li></ul><p><strong>LangChain’s Approach:</strong></p><ul><li>Provides templates to standardize prompt creation.</li><li>Ensures more consistent and reliable responses from AI models.</li></ul><p><strong>Prompt Engineering with LangChain:</strong></p><p><strong>Prompt Templates:</strong> Pre-defined templates for generating effective prompts, ideal for crafting string prompts, which utilizes Python’s `str.format syntax` for templating. It allows the creation of prompts with variable inputs that can be defined and passed dynamically. The `PromptTemplate` can handle any number of variables, and you can explicitly specify input_variables for additional validation, which can be helpful to ensure the prompts have the correct parameters before they are used.</p><p><strong>ChatPromptTemplate:</strong> For interactions with chat models, LangChain provides `ChatPromptTemplate`. This is used for a list of chat messages, where each message is associated with a role such as a system, AI, or human. This structure is particularly useful in applications like chatbots where the exchange between the AI and the user is back-and-forth, resembling a conversation.</p><p><strong>Applications:</strong></p><ul><li>Generating context-specific questions/queries.</li><li>Enhancing interactions with AI models in chat applications.</li></ul><p>Example of making a robust PromptTemplate in LangChain using Python:</p><pre>from langchain.prompts import PromptTemplate<br><br>template = &quot;&quot;&quot;<br>As a digital concierge, your function is to aid individuals in discovering <br>local dining options that cater to their taste preferences and dietary <br>requirements.<br><br>You will liaise with diverse data repositories, which encompass geospatial <br>datasets in GeoPandas DataFrames and GeoJSON formats, structured listings in <br>CSV files and SQL databases, as well as unstructured reviews in textual format.<br><br>Your mission is to deliver precise and relevant recommendations based on <br>the user&#39;s current location and dining preferences, intelligently navigating <br>the available data to address the user&#39;s requests.<br><br>Provide the Python code required for querying data repositories and synthesizing information.<br>RESTAURANT DATA OVERVIEW:<br>{dataframes_info} containing a pair of dataframes dfs[0] and dfs[1]<br><br>DATASETS: <br>{dfs} - where dfs[0] is designated as restaurant_df and dfs[1] as reviews_df<br><br>USER INQUIRY: <br>{input}<br><br>Present the results in a structured table, executing necessary computations, and furnish a narrative response.<br><br>RESPONSE:<br>{agent_scratchpad}<br>&quot;&quot;&quot;<br><br># Create the Prompt Template to handle the prompt, variables, and instructions<br>prompt = PromptTemplate(template=template, input_variables=[&quot;dataframe_info&quot;, &quot;dfs&quot;, &quot;input&quot;])```</pre><p>References: <a href="https://python.langchain.com/docs/modules/model_io/prompts/">Prompts in Langchain</a>, <a href="https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/">Prompt Templates in Langchain</a>.</p><p><strong>Vector Databases: Storage and Retrieval of Data</strong></p><p><strong>Vector databases</strong> are specialized databases that store data as vectors, which are essentially arrays of numbers that can represent various types of data, including text, images, audio, and other complex data types. They are fundamentally different from traditional relational databases or even NoSQL databases in several ways:</p><p><strong>Storage and Representation of Data</strong></p><ol><li>Vector Representation:</li></ol><ul><li>Vector Databases: Data is stored in the form of vectors, with each vector being a representation of the data in a high-dimensional space.</li><li>Traditional Databases: Data is typically stored in rows and columns, with each field holding scalar values (like strings, integers, dates).</li></ul><p><strong>Search Mechanisms</strong></p><p>2. Semantic Search:</p><ul><li>Vector Databases: Allow for semantic searches by finding the nearest neighbors to a query vector in the vector space, which can mean finding items that are similar in meaning or context.</li><li>Traditional Databases: Searches are generally exact-match or pattern-based (like SQL LIKE queries).</li></ul><p><strong>Handling Complex Data</strong></p><p>3. Complex and Unstructured Data:</p><ul><li>Vector Databases: Excel in handling unstructured data like text and images by converting them into vector embeddings which can then be compared for similarity.</li><li>Traditional Databases: Structured data fits well, but they are not inherently designed for unstructured data without additional processing.</li></ul><p><strong>Use Cases</strong></p><p>4. Use Cases:</p><ul><li>Vector Databases: Commonly used for recommendation systems, semantic text search, image retrieval, and any domain requiring the analysis of complex patterns or relationships.</li><li>Traditional Databases: Well-suited for applications that require ACID transactions, structured data, and predefined queries.</li></ul><p><strong>Why Are They Used?</strong></p><ul><li>Enable semantic searches: Finding items similar in meaning, not just in exact wording.</li><li>Enhance data analysis: Facilitate the handling of complex, unstructured data like text and images.</li></ul><p><strong>LangChain’s Approach:</strong></p><ul><li>Types: Chroma, FAISS, Lance, Pinecone, etc.</li><li>Use Cases: Semantic search, efficient data retrieval.</li></ul><p>Example of storing different document types into a Vector Database and Querying it using LangChain with Python:</p><pre>from langchain.document_loaders import PyPDFLoader, Docx2txtLoader<br>from langchain.text_splitter import CharacterTextSplitter<br>from langchain.vectorstores import FAISS<br>from langchain.llms import OpenAIEmbeddings<br><br># Paths to your PDF and Word documents<br>pdf_paths = [&quot;path/to/restaurant_menu_1.pdf&quot;, &quot;path/to/restaurant_menu_2.pdf&quot;]<br>docx_paths = [&quot;path/to/restaurant_menu_3.docx&quot;, &quot;path/to/restaurant_menu_4.docx&quot;]<br><br>pdf_documents = [PyPDFLoader(pdf_path).load_and_split() for pdf_path in pdf_paths]<br>docx_documents = [Docx2txtLoader(docx_path).load_and_split() for docx_path in docx_paths]<br><br># Flatten the list of lists for pdf and docx documents<br>pdf_documents = [doc for sublist in pdf_documents for doc in sublist]<br>docx_documents = [doc for sublist in docx_documents for doc in sublist]<br><br># Combine all documents into one list<br>documents = pdf_documents + docx_documents<br><br># Split the documents into chunks for embedding<br>text_splitter = CharacterTextSplitter(chunk_size=1500, chunk_overlap=200)<br><br>splits = text_splitter.split_documents(documents)<br><br># Initialize embeddings and FAISS vector database<br>openai_api_key = &#39;sk-… &#39; # replace the contents within the string with your key<br><br>embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key, model=&quot;text-embedding-ada-002&quot;)<br>vectordb = FAISS.from_documents(splits, embeddings)<br><br># Example: Use FAISS to find similar restaurant descriptions based on a query<br>query = &quot;What restaurants have huevos rancheros or Tex Mex food?&quot;<br>closest_restaurants = vectordb.similarity_search(query)<br><br># The `closest_restaurants_menus` variable contains the ids of the closest matches<br>print(closest_restaurants_menus)</pre><p>References: <a href="https://python.langchain.com/docs/modules/data_connection/vectorstores/">Vector Stores in Langchain</a>, <a href="https://python.langchain.com/docs/modules/data_connection/document_loaders/pdf">PDF Data Loader Langchain</a>, <a href="https://python.langchain.com/docs/integrations/document_loaders/microsoft_word">Word Data Loader Langchain</a>, <a href="https://python.langchain.com/docs/integrations/vectorstores/faiss">Langchain FAISS</a>, <a href="https://python.langchain.com/docs/modules/data_connection/text_embedding/">Langchain Embeddings</a>, <a href="https://python.langchain.com/docs/use_cases/question_answering/">Langchain Retrieval-Augmented Generation (RAG)</a></p><p><strong>Agents in Computing</strong></p><p>In the realm of Large Language Models (LLMs) and Natural Language Processing (NLP), an <strong>agent</strong> is essentially a software program designed to interact with language models for executing specific tasks. These agents autonomously process inputs, like user questions, utilizing LLMs to understand and respond to them. They are particularly integral in applications requiring real-time, intelligent language interaction, such as in conversational AI, automated customer service, and various other interactive AI-driven systems. Agents in this context bridge advanced language comprehension with practical, responsive actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Bl7snCy81iY7z2w7WQb8g.png" /></figure><p><strong>Introduction to Agents in LangChain</strong></p><p>Agents in LangChain are the core components that drive the decision-making and action execution within the framework. They determine sequences of actions based on tools or data available, user input, and previously executed steps to the LLM. LangChain offers various built-in agents, each with unique prompting styles and functionalities.</p><p><strong>Types of Agents:</strong></p><ul><li><a href="https://github.com/langchain-ai/streamlit-agent/blob/main/streamlit_agent/basic_streaming.py">Simple Streaming Agents</a></li><li><a href="https://github.com/langchain-ai/streamlit-agent/blob/main/streamlit_agent/basic_memory.py">Conversation Memory Agents</a></li><li><a href="https://github.com/langchain-ai/streamlit-agent/blob/main/streamlit_agent/search_and_chat.py">Internet Search Agent</a></li><li><a href="https://github.com/langchain-ai/streamlit-agent/blob/main/streamlit_agent/chat_pandas_df.py">Pandas DataFrame Agents</a> for data analysis</li></ul><p><strong>Examples:</strong></p><ul><li><a href="https://github.com/langchain-ai/streamlit-agent/blob/main/streamlit_agent/basic_streaming.py">Simple Streaming App</a>: For basic streaming functionalities.</li><li><a href="https://github.com/langchain-ai/streamlit-agent/blob/main/streamlit_agent/chat_with_documents.py">Chat with Documents</a>: Integrating chat functionalities with document retrieval.</li><li><a href="https://github.com/langchain-ai/streamlit-agent/blob/main/streamlit_agent/chat_with_sql_db.py">Chat with SQL DB</a>: Implementing chat interfaces with SQL database interactions.</li></ul><p><strong>Getting Started:</strong></p><ul><li>Setting up Streamlit applications with Langchain.</li><li>Implementing agents for specific tasks.</li></ul><p>Example of creating dataframe agent using LangChain — Python:</p><pre># Import necessary components from the Langchain library<br>from langchain.agents.agent_types import AgentType<br>from langchain.chat_models import ChatOpenAI<br>from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent<br><br># Your OpenAI API key<br>openai_api_key = &#39;sk….&#39;<br><br># Create the agent with the provided dataframes<br>agent = create_pandas_dataframe_agent(<br>  ChatOpenAI(temperature=0, openai_api_key=openai_api_key, model=&quot;gpt-4&quot;),<br>  [manhattan_restaurants_df, Brooklyn_restaurants_df], # list of dataframes<br>  handle_parsing_errors=True,<br>  agent_type=AgentType.OPENAI_FUNCTIONS,<br>)<br><br># Example usage of the agent to query the dataframes<br>response = agent.run(&quot;Find me a vegan restaurant in Manhattan with a rating above 4.5&quot;)<br>print(response)</pre><p>References: <a href="https://python.langchain.com/docs/modules/agents/">Langchain Agents</a>, <a href="https://python.langchain.com/docs/integrations/toolkits/pandas">Langchain DataFrame Agent</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ce23ca8d9a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Opportunities and Challenges of Immersive Technologies in Medicine]]></title>
            <link>https://medium.com/@stefanlehman2/opportunities-and-challenges-of-immersive-technologies-in-medicine-0e6ba5de36ca?source=rss-fc848fe6f5f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e6ba5de36ca</guid>
            <category><![CDATA[haptics]]></category>
            <category><![CDATA[immersive-technology]]></category>
            <category><![CDATA[medical-technology]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[virtual-reality]]></category>
            <dc:creator><![CDATA[Stefan Lehman]]></dc:creator>
            <pubDate>Mon, 04 Dec 2023 14:47:59 GMT</pubDate>
            <atom:updated>2023-12-04T14:47:59.598Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cMUyLIHjWQkmXXeTHJlZfQ.png" /></figure><p>By Stefan Lehman and Andrew Kant</p><h3>Introduction</h3><p>For the last few decades, many technical advancements in the digital world have not realized their fullest potential in the real, or physical world. The two domains are very much siloed with each experience largely contained within its respective environment. A major challenge in bridging these worlds is connecting our sense of touch, feel and space, alongside our visual field — arguably our two most dominant senses — together.</p><p>Lex Fridman and Mark Zuckerburg discuss this division in the Lex Fridman Podcast #398 — Mark Zuckerberg: First Interview in the Metaverse. Mark suggests that in the next five to ten years, new integrative technologies will bridge these sensory gaps and spawn new markets, use cases and a change in our daily lives (<a href="https://www.youtube.com/watch?v=MVYrJJNdrEg">Lex Fridman/Mark Zuckerburg Interview</a>). When constructing these systems, developers, engineers, and designers need to meticulously analyze how users interact and experience a system, encoding sensory, spatial and motor information.</p><p>So, change seems to be on the horizon in Big Tech, but what about healthcare?</p><p>Medicine and healthcare present a prime setting for integrating immersive and haptic technologies, as they enable understanding how the body interprets sensory and motor data. It’s vital to comprehend the intricacies of human anatomy, physiology, psychology, and biomechanics for realistic virtual and physical interactions. Systems must be adaptive, considering individual cognitive differences and incorporate various sensory inputs, including pressure, touch, and proprioception, to ensure genuine interactions across realms (<a href="https://www.ncbi.nlm.nih.gov/books/NBK547656/#:~:text=Broadly%2C%20sensations%20fall%20into%20two,hearing%2C%20taste%2C%20and%20smell.">NIH Physiology, Sensory System</a>; <a href="https://www.sciencedirect.com/topics/neuroscience/proprioception">Science Direct</a>). This exploration delves into designing systems rooted in medical scenarios, emphasizing the role and applications of immersive and haptic technologies in healthcare.</p><p>In this post we’ll examine the convergence of immersive and haptic technologies broadly, and in healthcare. And importantly, its huge potential in closing the gap between our digital and physical worlds.</p><h3>Immersive, Extended Reality (XR) Technology</h3><p>Immersive technologies provide users with visual, auditory, and proprioception (i.e., your body’s ability to sense the body within space) stimuli, enabling them to perceive and interact within virtual and real-world settings. Although seen as one technology, immersive technologies or Extended Reality, often referred to as XR, is an umbrella term used to denote the variety of emerging 3D visualization systems (<a href="https://www.interaction-design.org/literature/article/beyond-ar-vs-vr-what-is-the-difference-between-ar-vs-mr-vs-vr-vs-xr#:~:text=Augmented%20reality%20(AR)%3A%20a,a%20fully%2Dimmersive%20digital%20environment.">Interaction Design Foundation</a>).</p><p>Extended Reality varies based on how the user perceives and interacts with virtual objects. Virtual Reality (VR) consists of fully immersing a user into a virtual or digital system, while Augmented Reality (AR) consists of overlaying virtual objects within a user’s environment (<a href="https://blogs.nvidia.com/blog/2022/05/20/what-is-extended-reality/">Nvidia Reference</a>). Mixed reality not only overlays digital objects into the user’s environment but also enables them to interact with these objects in real-time.</p><h3>Haptics and XR</h3><p>Haptic systems offer tactile feedback reminiscent of the sensations experienced during gaming controller actions or smartphone alerts (<a href="https://www.businessinsider.com/guides/tech/what-are-haptics">Business Insider</a>). These systems deploy specific technologies to generate vibrations, such as the eccentric rotating mass (ERM) actuator. Beyond vibration-centric systems, haptics also encompasses force feedback mechanisms like the automobile’s Lane Keeping Assist (LKA) and innovations like ultrasound fields (<a href="https://www.ultraleap.com/haptics/">Ultraleap</a>).</p><p>While haptic feedback focuses on simulating touch, XR prioritizes the visualization of virtual entities and surroundings. Despite their distinct functionalities, haptics and XR amplify the overall experience of user sensation, interactivity, and immersion in the digital domain. As we delve deeper into the fusion of haptics and XR, it’s important to understand the key hardware components that ensure integration.</p><h3>XR Hardware Overview</h3><ul><li><strong>User Interfaces</strong>: Equipment ranging from headsets to screens or mobile devices display virtual elements, facilitating user interaction. Additionally, dedicated controllers or sensors guide user-system interactions.</li><li><strong>Tracking Devices</strong>: These employ sensors, accelerometers, gyroscopes, and both internal and external cameras. Their role is pivotal in recording the user’s surrounding environment, motion patterns, and even some physiological metrics, ensuring system responsiveness.</li><li><strong>Computational Power</strong>: Graphics Processing Units (GPUs) handle parallel processing, crucial for graphic rendition and machine learning model applications. Central Processing Units (CPUs), on the other hand, orchestrate the overall system and take on the demanding task of data processing, ensuring users experience almost real-time interactions.</li><li><strong>Connectivity</strong>: To ensure a seamless experience, system hardware must guarantee minimal latency, fostering real-time or near-real-time user interactions. A conventional method involves leveraging HDMI and USB cables to tether hardware to the web, reducing any latency.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-5asOzT6xUXV8zCZtkEjoQ.png" /></figure><h3>XR and Haptics for Medicine</h3><p>The need for medical professionals — including doctors, nurses, physical therapists, and students — to understand complex anatomy and physiology opens doors for developers and engineers. They have the opportunity to create rich immersive experiences that have tangible impacts in the real world. Surgeons and students can now visualize and practice intricate surgeries without the fear of real-world consequences.</p><p>In a clinical setting, immersive experiences powered by haptic technology are revolutionizing the way medical practitioners engage with digital or distant environments. Feedback in the form of forces and vibrations allows these professionals to use their sense of touch more dynamically. This technology lets them distinguish between different anatomical structures — like bones, tissues, and organs — through real-time tactile feedback, such as varying levels of force and pressure.</p><p>In medicine, the sense of touch is critically important — whether it’s for palpation in a physical exam or handling delicate tissue in a laparoscopic surgery. Doctors heavily depend on the sense of touch, so it’s clear haptics have a key role to play . As more technology is adopted in healthcare, there will be a race to perfectly mimic, and perhaps surpass, the feel that healthcare providers deeply depend on. So what are some use cases for this?</p><ul><li><strong>Medical Training and Simulation</strong>: Surgical simulation and training is critical, not only for trainees but surgeons learning new procedures. Haptics could increase the fidelity for real-life tactile sensations.</li><li><strong>Robotic Surgery</strong>: Robotic surgical systems are swiftly evolving, with haptic technology being crucial due to its role in interacting with the patient.</li><li><strong>Prosthetics and Bionics</strong>: Artificial devices that replace or enhance missing or damaged body parts, integrated with haptic technology to mimic natural sensation.</li><li><strong>Rehabilitation</strong>: Haptics can be used in physical therapy (PT) rehab to provide tactile feedback during exercises, enhancing muscle memory and guiding patients towards correct movement patterns.</li><li><strong>Enhanced Radiology</strong>: Using immersive technologies and imaging technologies, it may be possible to develop haptic technology to augment radiologic diagnoses non-invasively, to assess shape, size, and texture of a tumor, for instance.</li></ul><p>Summary</p><p>In recent decades, the digital and physical worlds have remained largely separate, with touch and vision as key senses bridging the divide. As discussed by Lex Fridman and Mark Zuckerberg, the next decade is set to witness technological advances that seamlessly blend these two realms. The healthcare sector presents a prime arena for these advancements. Understanding the intricacies of human anatomy, psychology, and biomechanics is crucial in designing systems that enable meaningful virtual and physical interactions. Immersive technologies, also known as Extended Reality (XR), and haptic feedback are the cornerstones of this integration. XR offers visual, auditory, and spatial sensations while haptic systems provide tactile feedback. Together, they are set to revolutionize the medical field. From surgical simulations and training to advanced robotic surgeries and prosthetic enhancements, the combination of XR and haptics offers myriad opportunities. In essence, the fusion of these technologies will not only redefine medical training and procedures but also have the potential to revolutionize patient care and diagnostic processes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e6ba5de36ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analytical Models of Haptic Feedback — Evaluations of Immersive Technologies Under the Hood]]></title>
            <link>https://medium.com/@stefanlehman2/analytical-models-of-haptic-feedback-evaluations-of-immersive-technologies-under-the-hood-ccc5900ecc26?source=rss-fc848fe6f5f7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccc5900ecc26</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[haptic-technology]]></category>
            <dc:creator><![CDATA[Stefan Lehman]]></dc:creator>
            <pubDate>Thu, 28 Sep 2023 03:33:09 GMT</pubDate>
            <atom:updated>2023-09-28T03:33:09.958Z</atom:updated>
            <content:encoded><![CDATA[<h3>Analytical Models of Haptic Feedback — Evaluations of Immersive Technologies Under the Hood</h3><p>Industry: Medical Devices</p><p>Companies: Engineering &amp; Computer Simulations, Inc (ECS), Mayo Clinic, HapticX</p><p>Client: US Department of Defense — Defense Health Agency</p><p>Case Study: <a href="https://www.auganix.org/ecs-partners-with-haptx-and-mayo-clinic-to-develop-haptics-based-mixed-reality-training-system-for-defense-health-agency/">ECS partners with HaptX and Mayo Clinic to develop haptics-based Mixed Reality training system for Defense Health Agency</a></p><h4>Background:</h4><p>With the ever increasing innovations into virtual, mixed, and augmented reality, medical experts are looking to use immersive technologies synced with medical equipment and devices to train the next generation of surgeons, perform remote operations, and integrate guided surgeries with real-time feedback. Immersive experiences rely not only on a plethora of cutting edge technologies but also on the human body to complete this interactive system. When processing any stimulus, the body receives sensory information, such as visual, auditory, and tactile data, cognitively processes it, and then responds in motor functions back to the system. Developing an immersive system reliant on physical and digital feedback, engineers and researchers are focusing on haptics, the study of proprioception — senses of pressure, position, touch, and movement. Haptic feedback generates forces and vibrations in response to a user’s action and motion in their virtual or remote environment. Thus, haptic devices are critical to build immersive experiences because they allow “users to <em>feel and interact</em> indirectly with an external environment through physical manipulation of the device”1.</p><p>Similar to an Xbox controller vibrating after an achievement in a video game, haptic devices provide users with physical stimulation as an output from the virtual environment. In the context of clinical immersive experience, the feedback forces and vibrations provide doctors and medical students the ability to use their body to sense and feel digital or remote environments. Haptic technology will enable these medical professionals to differentiate the various anatomical and physiological structures, i.e., bones, tissue, organs, with temporal, tactile (force, pressure) feedback in real-time2.</p><p>Considering the mechanisms needed to make a haptic system, some of the underlying technologies are obvious while others are less apparent. The physical components, such as sensors, actuators (motors), surgical tools, and headsets, as well as the network connectivity systems, such as cloud, 4G/5G, and bluetooth, are at the top of mind for the building blocks for this technology. Although these are all critical pieces, individuals often overlook the algorithms and data necessary for the practitioner to experience these virtual environments. Analytical models with clinical data consisting of anatomical, physiological, physical, device, and environmental information is imperative for immersive experience to simulate seemingly real surgeries.</p><p>Introduction:</p><p>In 2020, Engineering &amp; Computer Simulations (ECS) partnered with the Mayo Clinic and HaptX, a start up haptic device company, to win a US Defense Health Agency (DHA) contract. Their deliverable was to develop a surgical simulation platform to train medical personnel and integrate the system into the Army’s Synthetic Training Environment (STE)3. The contract required these companies to create an end product that encompasses “natural interactions” during the clinical simulations, suggesting a major technological hurdle was to provide users with instant haptic feedback3.</p><p>ECS integrated HaptX’s Glove and leveraged the Mayo Clinic’s medical expertise and clinical data to develop the training platform. Although not explicitly stated, central to this project’s success was the analytical models and clinical data for the haptic feedback technology. This following paper considers and explores how this partnership may have used data science to deliver this robust immersive clinical experience for the Department of Defense’s DHA.</p><h4>Analytics Models:</h4><h4>Designing the Simulation System:</h4><p>The ability to create an immersive experience to simulate surgery requires extensive amounts of data. Replicating the diverse environments of the human body, developers and data scientists need to work alongside Subject Matter Experiences (SMEs), notably seasoned surgeons, radiologists, and biomedical engineers, to render and mimic the human body. Their collaboration requires the collection, analysis, and interpretation of diverse data sets. Analytical models then play a role in organizing this multimodal data to assert the physical patterns necessary to generate the haptic feedback to the user.</p><p>The rendering system and feedback responses require extensive anatomical, physiological, haptic, imaging/sensor, and surgical procedural data, yet these data types are often unlabeled or contain minimal amounts of metadata. Developers and data scientists can leverage unsupervised learning, algorithms that identify patterns from unlabeled data, to categorize and group biological and physical information with the operation4. Although there are a variety of ways in classifying this clinical data into procedural groups, a simplic approach would consist of using K-means clustering as this unsupervised technique.</p><p>Consider an example of simulating coronary artery bypass surgery. Patient’s experience blockage in the left atrium of the heart, which the operation requires cardiothoracic surgeons insert a graft to enable blood to flow to the right ventricle5.</p><p>Given biological data, vital measurements, and haptic data, such as:</p><ul><li>Anatomical Data: 2D or 3D images of the patient’s heart and surrounding structures, such as the left and right ventricles, atrium, healthy coronary arteries, block coronary artery/arteries, and aorta. These images would be obtained from medical imaging, such as CT scans, chest x-rays, and MRIs, to create a realistic model of the heart and coronary arteries.</li><li>Physiological Data: Patient’s heart rate, blood pressure, oxygen saturation, respiration rate, and other vital signs. This information would be used to simulate the responses and activity of the heart and blood vessels during surgery, which these metrics would be gathered from pulse oximeters, blood pressure devices, and other wearable devices attached to the patient during surgery.</li><li>Haptic Data: Forces, like stiffness, compression, and elasticity, and tactile sensations of the surgical instruments during procedures.</li></ul><p>Use:</p><ul><li>K-means clustering</li></ul><p>To:</p><ul><li>Organize the data into different clusters to represent and simulate a patient’s heart during the operation for rendering and haptic feedback. For example, the anatomical data could be clustered based on the location and severity of the blockages in the coronary arteries, while the physiological data could be clustered based on the patient’s demographics, such as age, sex, socioeconomic status, and race, that could impact the surgical outcome. The haptic data could be clustered based on the force and pressure exerted by the surgeon and the instruments during different phases of the surgery.</li></ul><p>In summary, k-means clustering can categorize the data to train a machine learning model to simulate the surgery using a haptic device. The model would use the labeled data to predict the appropriate feedback to provide to the surgeon based on the specific anatomical and physiological conditions of the patient.</p><h4>User Interface — Instrument Location:</h4><p>To provide medical students and surgeons with a realistic experience of conducting surgery, the immersive surgical experience must continuously analyze the location of the surgical instrument to sync with the user and environment. The system needs to classify the surgical instrument’s movement and position, while the haptic device needs to predict a realistic response to the user. The system’s ability to process this information in real-time means the device requires built in analytical models for quick decision making. Although sophisticated neural networks are the first to come to mind, Support Vector Machines (SVMs), a supervised learning method of classifying and predicting higher dimensional data through the use of hyperplanes, is a simple yet highly effective method to group and predict the location of the user and instrument during surgical simulation.</p><p>Assessing the need to locate the instrument during user interactions, SVMs are an ideal candidate because of their ability to identify patterns in large and diverse datasets with seemingly little to no relationships. The attributes of the model to</p><p>Orthopedic surgery is a prime example where the instrument location is vital for the operation’s success and crucial in minimizing bone damage. In knee surgery specifically, the positioning of instruments such as scalpels, drills and saws in relation to the patient’s anatomy is paramount to achieve the desired results6. The training system’s ability to locate and position the surgical equipment when the doctor is using it is vital because slight deviances in positioning and location of the medical equipment during the simulation operation can lead to very serious and real complications, i.e. joint instability, pain, and bone malformations, in patients once the medical student is operating in real-life.</p><p>Given:</p><ul><li>Position of the instrument: Coordinate data points on a 3D Cartesian plane (x,y,z axes). The 3D location and orientation of the surgical instrument in the coordinate system of the patient’s knee joint needs to be captured by a 3D motion tracking system.</li><li>Direction of motion: Directional data the instrument is moving in — flexion, extension, rotation, etc, using a 3D Cartesian plane (x,y,z axes) to provide directional vectors. The data also needs to be obtained through a 3D motion capture system paired with videos or temporal images.</li><li>Anatomical Data: Knee tissue, such as the cartilage, meniscus, ligament, and bones (femur, tibia, patella), currently interacting with the instrument during the operation.</li><li>Haptic Data — Magnitude and direction of the force and torque applied by the surgeon to the instrument. Although this would be ideal, this data might not be collected depending on the instruments used during the operation. The data could be collected based on the other groups of data.</li><li>Previous Successful Operations: Motions, pressures, and forces exerted by professional surgeons during successful operations. Considerations of labeled or annotated procedures would enable the user to guide through the current step of the procedure being performed — cutting, scraping, drilling, etc.</li></ul><p>Use:</p><ul><li>Support Vector Machines (SVM)</li></ul><p>To:</p><ul><li>Predict the position and orientation of a surgical instrument in relation to the knee joint as the surgeon performs the virtual surgery.</li></ul><p>In summary, Support Vector Machines enable the surgical system to locate and respond to the surgical device’s position and movements by grouping captured position data and predicting the next positions</p><h4>User Interface — Tool-Tissue Interactions:</h4><p>Once the system renders the organs and locates the user with the surgical tool, the ability to mimic similar forces, pressures, and vibrations during surgery is necessary to facilitate realistic user interactions. The user’s perception of “feeling” different anatomical parts is a result of analytical models harmonizing the various input data to synchronize the system’s output feedback. Although difficult to obtain labeled datasets with this kinematic data, supervised learning is an ideal fit. Classification and regression models, forms of supervised learning, enable the system to distinguish different anatomical body parts and predict the necessary kinematics generated in the haptic device. Decision tree’s ability to classify and predict</p><p>Decision trees can model how forces need to change depending on the anatomical structure being interacted with. Organs, like the heart, stomach, and eyes, and tissues, such as bone, muscle, and blood vessels, will require different levels of force applied to the surgical instrument. The decision tree can identify key anatomical structures based on the location and motion data from the haptic device. It then determines what force feedback to provide based on that anatomical context. As the tool moves from one structure to another, the decision tree dynamically adjusts the force feedback to match what would be required for that new structure.</p><p>In an example of cataract surgery, ophthalmologists use their surgical tools to evaluate their patients’ eyes and perform delicate procedures. Ophthalmologists use their surgical instruments to gauge intraocular pressure during this operation. The ability for haptic devices to transmit the haptic feedback with the same level of pressure, force, and vibrations is crucial for practicing medical students.</p><p>Given:</p><ul><li>Anatomical Data: 2D and 3D images of the patient’s eye obtained, including the cornea, iris, lens, ciliary body, and vitreous humor with the structure’ dimensions and shapes. Ophthalmologists obtain this data during visits prior to the operation.</li><li>Physiological Data: Eye pressure (extraocular and intraocular pressures), movements, and rotations captured in pre-surgery screenings and day of operation measurements.</li><li>Haptic Data: Forces exerted on the surgical instruments captured during cataract procedures (corneal incision, capsulorhexis, phacoemulsification, and lens implantation)7. Additionally, tactile forces gathered from interacting with the eye’s structure during the procedure, i.e., cornea, iris, lens, and vitreous humor tissues.</li><li>Motion Data: Position, orientation, velocity, and acceleration of the surgical instruments during the surgery. Although this would be ideal, this data might not be collected depending on the instruments used during the operation. The data could be collected based on the other groups of data.</li></ul><p>Use:</p><ul><li>Decision tree models</li></ul><p>To:</p><ul><li>Determine the appropriate level of force to apply based on the user’s interactions with the various anatomical and physiological renderings. More specifically, the use of decision tree models predicts force and tactile feedback to the surgeon depending on the current anatomical structure of the eye, position, motion, and state of the surgical instrument.</li></ul><p>In summary, decision trees can provide users with context-sensitive force feedback. The model’s ability to classify and predict how forces enable the haptic device to generate varying forces depending on the physiological environment within the body.</p><h4>Conclusion:</h4><p>In conclusion, the ability for an immersive surgical training system to be successful is dependent on the system’s haptic devices to generate realistic forces and sensations for the surgeon or medical student to feel the virtual or remote environment. The haptic device’s built-in analytical models allow the system to respond in real-time. The partnership among ECS, HaptX, and the Mayo Clinic for DHA contract to build a surgical training system was not only a difficult mechanical and software engineering project but also a complex data science problem.</p><p>Although their development and models are not public, haptic devices encompass a variety of analytical models to analyze, predict, and respond to input data in real-time. The use of K-means clustering is ideal for the digital system to classify the tissues and their associated forces for generating the haptic feedback. SVM’s properties of identifying relationships in multimodal data serve as a simplistic but effective method to locate and predict the surgical instrument, keeping the haptic device in sync with the user. Lastly, the ability to use Decision Trees based on clarification and regression aids the haptic device to generate context-based feedback based on the interactions with physiological tissue and the user’s surgical tool.</p><h4>References:</h4><p><a href="https://www.sciencedirect.com/book/9780323961011/modeling-and-nonlinear-robust-control-of-delta-like-parallel-kinematic-manipulators"><strong>1</strong>https://www.sciencedirect.com/book/9780323961011/modeling-and-nonlinear-robust-control-of-delta-like-parallel-kinematic-manipulators</a></p><p><a href="https://bme240.eng.uci.edu/students/09s/hokabe/Surgical_Simulation_Through_Haptic_Technology/Introduction.html">2https://bme240.eng.uci.edu/students/09s/hokabe/Surgical_Simulation_Through_Haptic_Technology/Introduction.html</a></p><p><a href="https://www.auganix.org/ecs-partners-with-haptx-and-mayo-clinic-to-develop-haptics-based-mixed-reality-training-system-for-defense-health-agency/">3https://www.auganix.org/ecs-partners-with-haptx-and-mayo-clinic-to-develop-haptics-based-mixed-reality-training-system-for-defense-health-agency/</a></p><p><a href="https://www.ibm.com/topics/unsupervised-learning">4https://www.ibm.com/topics/unsupervised-learning</a></p><p><a href="https://www.mayoclinic.org/tests-procedures/coronary-bypass-surgery/about/pac-20384589">5https://www.mayoclinic.org/tests-procedures/coronary-bypass-surgery/about/pac-20384589</a></p><p><a href="https://www.aorn.org/outpatient-surgery/article/2020-July-positioning-is-paramount-in-orthopedics">6https://www.aorn.org/outpatient-surgery/article/2020-July-positioning-is-paramount-in-orthopedics</a></p><p><a href="https://www.ncbi.nlm.nih.gov/books/NBK576419/">7https://www.ncbi.nlm.nih.gov/books/NBK576419/</a></p><p><a href="https://www.frontiersin.org/articles/10.3389/frobt.2020.586707/full">https://www.frontiersin.org/articles/10.3389/frobt.2020.586707/full</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccc5900ecc26" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>