<?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 Naomi Fridman on Medium]]></title>
        <description><![CDATA[Stories by Naomi Fridman on Medium]]></description>
        <link>https://medium.com/@naomi-fridman?source=rss-f2f4a8de7de5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ND-oxkmOEZfw_T8OLzBbwA.jpeg</url>
            <title>Stories by Naomi Fridman on Medium</title>
            <link>https://medium.com/@naomi-fridman?source=rss-f2f4a8de7de5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 09:16:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@naomi-fridman/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[BreastDCEDL: A Dynamic Contrast-Enhanced Breast MRI Dataset]]></title>
            <link>https://medium.com/data-science-collective/breastdcedl-a-dynamic-contrast-enhanced-breast-mri-dataset-e3c69529dff9?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3c69529dff9</guid>
            <category><![CDATA[dataset]]></category>
            <category><![CDATA[dce-mri-dataset]]></category>
            <category><![CDATA[breat-mri]]></category>
            <category><![CDATA[breast-cancer-dce-mri]]></category>
            <category><![CDATA[breast-cancer]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 07:30:35 GMT</pubDate>
            <atom:updated>2025-12-25T14:19:55.118Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://colab.research.google.com/github/naomifridman/BreastDCEDL/blob/main/BrestDCEDL_zenodo_demo.ipynb">Demo Notebook</a> | <a href="https://github.com/naomifridman/BreastDCEDL">GitHub</a> | <a href="https://arxiv.org/abs/2506.12190">Paper</a></p><p>BreastDCEDL is a curated, deep learning–ready dataset of 3D DCE-MRI scans from 2,070 breast cancer patients across three major clinical trials (I-SPY1, I-SPY2, Duke) available through The Cancer Imaging Archive (TCIA). The dataset includes pre-treatment MRI volumes, 3D tumor segmentations, and harmonized clinical and demographic metadata, including pathologic complete response (pCR), hormone receptor (HR), and HER2 status. This resource supports advanced AI research in breast cancer, enabling training and evaluation of transformer-based and other deep learning models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1Ubb9hUpVEuZtrwVWXt8Q.png" /><figcaption>BreastDCEDL Examples: Top row: RGB fusion images. Middle row: RGB fusion with tumor overlay. Bottom row: binary tumor masks. Columns represent samples from ISPY2, ISPY1, and Duke datasets.</figcaption></figure><h3>Understanding DCE-MRI: Watching Tumors Light Up</h3><p>Dynamic Contrast-Enhanced MRI (DCE-MRI) is like creating a time-lapse movie of blood flow through tissue. Patients receive an injection of gadolinium contrast agent, and the MRI scanner captures multiple 3D images over several minutes. Tumors “light up” differently than healthy tissue — they enhance rapidly and wash out quickly due to their abnormal blood vessels. Radiologists analyze three key moments: before contrast (baseline), peak enhancement (revealing tumor vascularity), and washout phase (showing contrast clearance patterns). These enhancement dynamics help distinguish malignant from benign lesions and predict treatment response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rmF0DFriEg-o9Pcv" /></figure><p><em>The three critical DCE-MRI phases used for clinical assessment and AI model training</em></p><h3>DCE-MRI 3D Data Organization</h3><h3>Data Structure</h3><p>The dataset provides standardized 3D NIfTI volumes capturing breast tissue at three critical time points during contrast enhancement. Each patient has:</p><ul><li><strong>Pre-contrast baseline</strong> (before gadolinium injection)</li><li><strong>Early post-contrast</strong> (peak enhancement, ~2 minutes post-injection)</li><li><strong>Late post-contrast</strong> (washout phase, ~5–7 minutes post-injection)</li></ul><h3>Contrast Dynamics</h3><p>Following intravenous gadolinium injection, the contrast agent circulates through blood vessels and leaks into tissue. Malignant tumors exhibit characteristic rapid uptake and washout patterns due to abnormal vasculature and increased permeability. These temporal enhancement patterns, captured across the three time points, reveal crucial diagnostic information about tumor biology and aggressiveness.</p><h3>Segmentation Data</h3><p>Each case includes expert-verified 3D tumor segmentation masks (binary NIfTI files) delineating the complete tumor volume. These masks align spatially with the MRI volumes, enabling precise region-of-interest analysis and serving as ground truth for training segmentation algorithms. The segmentation covers all malignant tissue visible across the enhancement phases.</p><h3>File Organization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wtZhTMuiLSeaiMazsQpUqA.png" /><figcaption>BreastDCEDL file organization</figcaption></figure><h3>The Datasets: Three Perspectives on Breast Cancer</h3><h3>I-SPY2: The Largest Cohort (n=982)</h3><p>The I-SPY2 trial represents the backbone of BreastDCEDL, contributing nearly half of all patients. Collected from 2010–2016 across 22+ clinical centers, these scans follow a standardized protocol ensuring consistency despite the multi-institutional nature. Each patient has 3–12 time points (typically 7), with radiologists selecting three key phases for clinical analysis. The trial focused on high-risk, locally advanced breast cancers, providing rich data for predicting treatment response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*MiVwcv9iwsmmwG6DdHuw3Q.png" /><figcaption>BreastDCEDL_ISPY2 examples: Top row: RGB fusion images. Middle row: RGB fusion with tumor overlay. Bottom row: Segmentation masks.</figcaption></figure><p>BreastDCEDL_ISPY2 examples: Top row: RGB fusion images. Middle row: RGB fusion with tumor overlay. Bottom row: Segmentation masks.</p><h3>I-SPY1 (n=172)</h3><p>I-SPY1 dataset offers DCE MRI imaging data with slightly different acquisition protocols. Despite being smaller, it provides valuable validation data for testing model generalization across different imaging standards. The dataset includes 3–5 DCE scans per patient with complete tumor segmentations, making it ideal for temporal analysis studies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*Yv8bZf58xp-WvANlWjWE7g.png" /><figcaption>BreastDCEDL_ISPY1 examples: Top row: RGB fusion images. Middle row: RGB fusion with tumor overlay. Bottom row: Segmentation masks.</figcaption></figure><p>BreastDCEDL_ISPY1 examples: Top row: RGB fusion images. Middle row: RGB fusion with tumor overlay. Bottom row: Segmentation masks.</p><h3>Duke: High-Resolution Imaging (n=916)</h3><p>The Duke dataset brings diversity in resolution and acquisition parameters. Collected between 2000–2014, these scans often use higher spatial resolution (512×512) compared to the I-SPY trials. While only 31% of Duke patients received neoadjuvant chemotherapy (providing pCR labels), the dataset offers unique insights into tumor morphology. Unlike I-SPY datasets, Duke provides bounding boxes rather than full segmentations, presenting interesting challenges for automated analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*POlHcSTJKVmKdIT7FUHB1w.png" /><figcaption>BreastDCEDL_DUKE examples: Top row: RGB fusion images. Middle row: RGB fusion with tumor overlay. Bottom row: Segmentation masks.</figcaption></figure><p>BreastDCEDL_DUKE examples: Top row: RGB fusion images. Middle row: RGB fusion with tumor overlay. Bottom row: Segmentation masks.</p><h3>Two Versions for Different Research Needs</h3><h3>MinCrop Version: Ready for Immediate Use</h3><p>The MinCrop version (25 GB) provides the essential data for most deep learning applications. Each patient has three 256×256 crops centered on the tumor at the clinically relevant time points. This standardized format has already yielded state-of-the-art results: AUC 0.94 for pCR prediction and 0.74 for HER2 status classification.</p><h3>Full Version: Complete Spatiotemporal Data</h3><p>The Full version (~206 GB) preserves all temporal acquisitions at original resolution, enabling advanced research into contrast kinetics and spatial relationships beyond the tumor region. Perfect for developing novel preprocessing methods or investigating the full complexity of enhancement patterns.</p><h3>Impact and Applications</h3><p>BreastDCEDL addresses a critical gap in medical AI research. Previous studies were limited to small, single-institution datasets, making it difficult to develop generalizable models. With 2,070 patients and standardized preprocessing, researchers can now:</p><ul><li>Train transformer architectures that require large datasets</li><li>Benchmark different AI approaches on consistent data splits</li><li>Validate models across multiple institutions</li><li>Explore the relationship between imaging features and molecular subtypes</li></ul><p>The dataset has already demonstrated its value, with published research showing that Vision Transformers can predict treatment response with remarkable accuracy in specific patient subgroups.</p><h3>Getting Started</h3><pre>demo https://colab.research.google.com/github/naomifridman/BreastDCEDL/blob/main/BrestDCEDL_zenodo_demo.ipynb</pre><h3>Open Science for Better Outcomes</h3><p>By making BreastDCEDL publicly available, we aim to accelerate AI development in breast cancer imaging. The standardized format, clinical annotations, and benchmark splits ensure reproducible research. Whether you’re developing radiomics pipelines, training CNNs, or exploring transformers, this dataset provides the foundation for advancing personalized breast cancer care.</p><p><strong>Access the data</strong>: <a href="https://zenodo.org/records/15627233">Zenodo</a> | <strong>Explore examples</strong>: <a href="https://colab.research.google.com/github/naomifridman/BreastDCEDL/blob/main/BrestDCEDL_zenodo_demo.ipynb">Colab Demo</a></p><h3>Citation</h3><p>If you use BreastDCEDL in your research, please cite our work:</p><pre>@article{fridman2025breastdcedl,<br>  title={BreastDCEDL: A Comprehensive Breast Cancer DCE-MRI Dataset and <br>         Transformer Implementation for Treatment Response Prediction},<br>  author={Fridman, Naomi and Solway, Bubby and Fridman, Tomer and <br>          Barnea, Itamar and Goldstein, Anat},<br>  journal={arXiv preprint arXiv:2506.12190},<br>  year={2025},<br>  doi={10.48550/arXiv.2506.12190}<br>}</pre><p><em>Naomi Fridman is a researcher at Ariel University focusing on medical AI applications. This dataset was developed to support reproducible research in breast cancer imaging.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3c69529dff9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/breastdcedl-a-dynamic-contrast-enhanced-breast-mri-dataset-e3c69529dff9">BreastDCEDL: A Dynamic Contrast-Enhanced Breast MRI Dataset</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C Code — Beginners Practice]]></title>
            <link>https://medium.com/geekculture/c-code-beginners-practice-9c4204925feb?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c4204925feb</guid>
            <category><![CDATA[exercise]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Sun, 07 Nov 2021 16:02:09 GMT</pubDate>
            <atom:updated>2021-11-14T17:48:43.120Z</atom:updated>
            <content:encoded><![CDATA[<h3>C Beginners, Nested For Loops</h3><p>More C code beginners exercise with solutions. This Time we focus on nested loops. First part about basic for loops is <a href="https://naomi-fridman.medium.com/c-beginners-practice-for-loop-4933a368d966">here</a>.</p><figure><img alt="https://pixabay.com/photos/bird-nest-bird-s-nest-robin-egg-2171412/" src="https://cdn-images-1.medium.com/max/1024/1*OhsxkaLOIU_3D-Sgk3XLgw.jpeg" /></figure><h3>Nested For Loop</h3><p>Loops can be nested. Meaning, you can use a for loop inside a for loop, going as deep as you like. Usually more then 2–3 nesting&#39;s, is to complicated to follow. Bellow is a simple example, you can play around with to understand the nesting:</p><pre>for (i=1; i &lt;=n ; i++) {<br>    <br>    printf(&quot;\n&quot;); <br>    <br>    for (j=1; j &lt;=i ; j++) {<br>       <br>       printf(&quot; %d&quot;, j); <br>    }<br>}</pre><p>Output for n = 5:</p><pre>Enter a positive number n: 5</pre><pre> 1<br> 1 2<br> 1 2 3<br> 1 2 3 4<br> 1 2 3 4 5</pre><p>Another simple example:</p><pre>for (i=1; i &lt;=n ; i++) {<br>    <br>    printf(&quot;\n ** starting outer loop i = %d \n &quot;, i); <br>    <br>    for (j=1; j &lt;=n ; j++) {<br>       <br>       printf(&quot; (i, j) = (%d, %d) &quot;, i, j); <br>    }<br>}</pre><p>Output for input n=4:</p><pre>Enter a positive number n: 4</pre><pre>** starting outer loop i = 1 <br>  (i, j) = (1, 1)  (i, j) = (1, 2)  (i, j) = (1, 3)  (i, j) = (1, 4) <br> ** starting outer loop i = 2 <br>  (i, j) = (2, 1)  (i, j) = (2, 2)  (i, j) = (2, 3)  (i, j) = (2, 4) <br> ** starting outer loop i = 3 <br>  (i, j) = (3, 1)  (i, j) = (3, 2)  (i, j) = (3, 3)  (i, j) = (3, 4) <br> ** starting outer loop i = 4 <br>  (i, j) = (4, 1)  (i, j) = (4, 2)  (i, j) = (4, 3)  (i, j) = (4, 4)</pre><h3>Exercises</h3><p>For each exercise, the expected output is given. Your mission is to produce the same output.</p><ol><li>Print a tringle of numbers. each number printed #number of times.</li></ol><pre>Enter a positive number n: 6<br> 1<br> 2 2<br> 3 3 3<br> 4 4 4 4<br> 5 5 5 5 5<br> 6 6 6 6 6 6</pre><p>2. Print square of start of the given size.</p><pre>Enter a positive number n: 5<br>*****<br>*   *<br>*   *<br>*   *<br>*****</pre><p>3. Print upside down triangle number, in the following format:</p><pre>Enter a positive number n: 6<br> 1 2 3 4 5 6<br> 1 2 3 4 5<br> 1 2 3 4<br> 1 2 3<br> 1 2<br> 1</pre><p>4. Print the following number triangle, for a given number.</p><pre>Enter a positive number n: 6<br> 6<br> 6 5<br> 6 5 4<br> 6 5 4 3<br> 6 5 4 3 2<br> 6 5 4 3 2 1</pre><p>5. Check if a given number is primal, if not, print all its denominators. For another variation, add a printout of the number of denominators.</p><pre>Enter a positive number n: 8<br>4 is denominator of 8<br> 4 * 2 = 8<br>2 is denominator of 8<br> 2 * 4 = 8</pre><p>Or</p><pre>Enter a positive number n: 7<br>7 is primal, has no denominators</pre><p>6. Print an X shape, of x’s, at the given size</p><pre>Enter a positive number n: 9<br>x      x <br> x    x  <br>  x  x   <br>   xx    <br>   xx    <br>  x  x   <br> x    x  <br>x      x</pre><p>7. Variation on 6 exercise, add a frame to the print.</p><pre>Enter a positive number n: 11<br>xxxxxxxxxxx<br>xx      x x<br>x x    x  x<br>x  x  x   x<br>x   xx    x<br>x   xx    x<br>x  x  x   x<br>x x    x  x<br>xx      x x<br>xxxxxxxxxxx</pre><p>To write and run your C code, you can use one of the online C compilers website. I use <a href="https://www.onlinegdb.com/online_c_compiler">https://www.onlinegdb.com/online_c_compiler</a>, and its great.</p><h3>Solutions</h3><p>Solution 1</p><pre>for (i=1; i &lt;=n ; i++) {<br>    <br>    <br>    for (j=1; j &lt;=i ; j++) {<br>       <br>       printf(&quot; %d&quot;, i); <br>    }<br>    printf(&quot;\n&quot;);<br>}</pre><p>Solution 2</p><pre>for (i=1; i &lt;=n; i++) {<br>    <br>    printf(&quot;*&quot;);<br>}<br>printf(&quot;\n&quot;);<br>for (i=2; i &lt;=n-1; i++) {<br>    printf(&quot;*&quot;);<br>    for (j=2; j &lt;=n-1 ; j++) {<br>       <br>       printf(&quot; &quot;); <br>    }<br>    printf(&quot;*\n&quot;);<br>}<br>for (i=1; i &lt;=n; i++) {<br>    <br>    printf(&quot;*&quot;);<br>}</pre><p>Solution 3</p><pre>for (i=n; i &gt;= 1; i--) {<br>    <br>    <br>    for (j=1; j &lt;=i ; j++) {<br>       <br>       printf(&quot; %d&quot;, j); <br>    }<br>    printf(&quot;\n&quot;);<br>}</pre><p>Solution 4</p><pre>for (i=1; i &lt;=n; i++) {<br>    <br>    for (j=1; j &lt;=i ; j++) {<br>       <br>       printf(&quot; %d&quot;, n - j +1); <br>    }<br>    printf(&quot;\n&quot;);<br>}</pre><p>Solution 5</p><pre><br>int i,j,n, is_primal = 1;</pre><pre>printf(&quot;Enter a positive number n: &quot;); <br>scanf(&quot;%d&quot;,&amp;n);</pre><pre>for (i=2; i &lt;n ; i++) {<br>    for (j=1; j &lt;=n ; j++) {<br>       <br>        if (j*i == n){<br>        <br>            printf(&quot;%d is denominator of %d\n &quot;, j, n); <br>            printf(&quot;%d * %d = %d\n&quot;, j,i, n); <br>            is_primal = 0;<br>            break;<br>    <br>         }<br>     }<br>}<br>if (is_primal) {<br>    printf(&quot;%d is primal, has no denominators \n &quot;, n); <br>}</pre><p>Solution 6</p><pre>for (i=1; i &lt;=n-1; i++) {<br>    <br>    for (j=1; j &lt;=n ; j++) {<br>       <br>       if (j==i | j==n-i){<br>         printf(&quot;x&quot;);   <br>       } else{<br>         printf(&quot; &quot;); <br>       }<br>    }<br>    printf(&quot;\n&quot;);<br>}</pre><p>Solution 7</p><pre>for (i=1; i &lt;=n-1; i++) {<br>    <br>    for (j=1; j &lt;=n ; j++) {<br>       <br>       if (j==i | j==n-i | i==1 | j==1 | j==n | i==n-1){<br>         printf(&quot;x&quot;);   <br>       } else{<br>         printf(&quot; &quot;); <br>       }<br>    }<br>    printf(&quot;\n&quot;);<br>}</pre><p><a href="https://naomi-fridman.medium.com/c-beginners-practice-for-loop-4933a368d966">c-beginners-practice-for-loop</a> &lt; — Previous Chapter on simple for loops</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c4204925feb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/c-code-beginners-practice-9c4204925feb">C Code — Beginners Practice</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C Beginners Practice — For Loop]]></title>
            <link>https://naomi-fridman.medium.com/c-beginners-practice-for-loop-4933a368d966?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4933a368d966</guid>
            <category><![CDATA[c]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[for-loop]]></category>
            <category><![CDATA[practice]]></category>
            <category><![CDATA[beginner]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Sun, 07 Nov 2021 15:14:16 GMT</pubDate>
            <atom:updated>2021-11-07T17:10:15.626Z</atom:updated>
            <content:encoded><![CDATA[<h3>C Beginners Practice — For loop</h3><h3>The For Loop</h3><p>A dear friend of mine, Aviv Ativ, is a student that learning a C coding course. To assist her in practice, I was looking for a good exercise resources. But, I didn&#39;t found enough simple basic training. So I decided to write one. Enjoy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBjLwDzWTwwEA-OKirqlcg.jpeg" /><figcaption><a href="https://pixabay.com/photos/fair-fairground-ferris-wheel-540126/">https://pixabay.com/photos/fair-fairground-ferris-wheel-540126/</a></figcaption></figure><h4>The For loop syntax</h4><p>In the for loop, we perform the same code again and again, each time with a different value of the counter. The loop stops, when the check statement is not True anymore.</p><pre>for (<strong>Initialize</strong> counter; <strong>Check</strong> weather to continue; <strong>Update </strong>counter)<br>{<br>    // *** Code that will be performed again and again<br>    // until the loop stops.<br>}</pre><p>Basic example. Lets print all the natural number up to 10:</p><ul><li>Initialize:<strong> </strong>i = 1<strong>, </strong>our counter is i, and we initialize it to 1.</li><li>Check: i &lt; 11 , when i will be smaller then 11, the loop will be performed again. when the check statement: i &lt; 11 will be false, the loop will stop, and the code will continue running from after the for loop block.</li><li>Update: i++ , after every one run of the loop , i will be incriminated by 1.</li></ul><pre>// Print natural numbers from 1 to 10<br>#include &lt;stdio.h&gt;<br><br>int main() {<br>  int i;<br><br>  for (i = 1; i &lt; 11; i++)<br>  {<br>    printf(&quot;%d &quot;, i);<br>  }<br>  return 0;<br>}</pre><p>Output</p><pre>1 2 3 4 5 6 7 8 9 10</pre><h4>Use few variables in a for loop</h4><p>You can use more then one variable in the for loop. Each variable, can be initialized, used for the stop check, and get to be updated in each loop run. In the following example, we use k to count how many times the loop was running. Tip, you can use it in exercise 6.</p><pre>#include&lt;stdio.h&gt;<br>void main() {<br>   int i,n, k;</pre><pre>printf(&quot;Input positive number n: &quot;); <br>   scanf(&quot;%d&quot;,&amp;n);</pre><pre>   for (i=3, k = 1; i&lt;=n; i=i+3, k++) {</pre><pre>      printf(&quot; The loop is running the #%d time. i = %d\n&quot;,k, i);<br>   }<br>}</pre><p>Output:</p><pre>Input positive number n: 11<br> The loop is running for the #1 time. i = 3<br> The loop is running for the #2 time. i = 6<br> The loop is running for the #3 time. i = 9</pre><h4>Break statement</h4><p>Break statement, breaks the loop. Meaning it stops the loop when its called, even if the stop condition defined in the loop is not met. Usually using break in a for loop is bad coding practice, but its important to be aware of the option. In the following example, we break the loop if the user enters negative number, instead of positive.</p><pre>int i,n;</pre><pre>for (i=0; i &lt; 10; i++) {<br>    printf(&quot;Enter a positive number n: &quot;); <br>    scanf(&quot;%d&quot;,&amp;n);</pre><pre>    if (n &lt; 0) {<br>        printf(&quot; %d is not a positive number! Loop is stopped.&quot;, n);<br>        break;<br>    }<br>    printf(&quot; ** you entered n = %d\n&quot;,n); <br>}</pre><p>Output</p><pre>Enter a positive number n: 7<br> ** you entered n = 7<br>Enter a positive number n: 2<br> ** you entered n = 2<br>Enter a positive number n: -1<br> -1 is not a positive number! Loop is stopped.</pre><p>To write and run your C code, you can use one of the online C compilers website. I use <a href="https://www.onlinegdb.com/online_c_compiler">https://www.onlinegdb.com/online_c_compiler</a>, and its great.</p><h3>Exercises</h3><p>For each exercise, the expected output is given. Your mission is to produce the same output.</p><ol><li>Print all the even numbers, up to a given number.</li></ol><pre>Enter a positive integer: 16<br>Positive numbers in 1...16 are:  2  4  6  8  10  12  14  16</pre><p>2. Print the sum of all numbers up to a given number.</p><pre>Enter a positive integer: 5<br>Sum of all numbers 1...5 = 15</pre><p>3. Print all the number divided by 3, up to a given number, and their sum.</p><pre>Enter a positive integer: 16<br> 3 + 6 + 9 + 12 + 15  = 45</pre><p>4. Ask the user to input 4 number between 1 and 100. Print min and max.</p><pre>Input number between 0-100 # 1: 7<br>Input number between 0-100 # 2: 56<br>Input number between 0-100 # 3: 3<br>Input number between 0-100 # 4: 88<br> The Maximum # is 88<br> The Minimum # is 3</pre><p>5. Print elements of arithmetic series, and Find the sum. a0, d and n are given.</p><pre>Input first series number a0: 2<br>Input the denominator d: 3<br>Input series length n: 4<br>5 8 11 14  The sum  is 40</pre><p>6. Divide given number by 3, if dividable, else print that its not.</p><pre>Input a number n: 9<br> 9 divided by 3 = 3</pre><p>or</p><pre>Input a number n: 5<br> 5 is not divided by 3</pre><h4>Solutions</h4><pre>// Solution 1<br>#include &lt;stdio.h&gt;<br>int main()<br>{<br>    int num, i, sum = 0;</pre><pre>    printf(&quot;Enter a positive integer: &quot;);<br>    scanf(&quot;%d&quot;, &amp;num);<br>    printf(&quot;Positive numbers in 1...%d are: &quot;, num);<br>    <br>    for(i = 2; i &lt;= num; i = i+2)<br>    {<br>        printf(&quot; %d &quot;,i);<br>    }</pre><pre>printf(&quot;\n&quot;);</pre><pre>return 0;<br>}</pre><p>Solution 2</p><pre>#include &lt;stdio.h&gt;<br>int main()<br>{<br>    int num, i, sum = 0;</pre><pre>    printf(&quot;Enter a positive integer: &quot;);<br>    scanf(&quot;%d&quot;, &amp;num);<br>    for(i = 1; i &lt;= num; i++)<br>    {<br>        sum += i; // same as sum = sum + i<br>    }</pre><pre>    printf(&quot;Sum of all numbers 1...%d = %d&quot;,num, sum);</pre><pre>    return 0;<br>}</pre><p>In the next solutions, we will write only the “important” part of the code.</p><p>Solution 3:</p><pre>int sum = 0;<br>for(i = 3; i &lt;= num; i = i+3) {<br>        if (i + 3 &gt; num) {<br>            // In the last numbers, = (not +) is printed<br>            printf(&quot; %d = &quot;, i);<br>        } else {<br>            printf(&quot; %d +&quot;, i);<br>        }<br>        sum += i; // same as sum = sum + i<br>        <br> }<br> printf(&quot;%d\n&quot;,sum);</pre><p>Solution 4:</p><pre>Min = 101; Max = 0;<br>// Call the First number as current maximum and minimum<br>for (x=1;x&lt;=4;++x) <br>{ <br>    printf(&quot;Input number between 0-100 # %d: &quot;,x); <br>    scanf(&quot;%d&quot;,&amp;Inp);<br>    if (Inp&gt;Max) {<br>       // if the next number is bigger than current maximum, store it <br>       Max = Inp;<br>    } <br>    if(Inp&lt;Min) {<br>        // if the next number is lower than current minimum, store it</pre><pre>Min = Inp; <br>    } <br>} <br>printf(&quot; The Maximum # is %d\n&quot;,Max);<br>printf(&quot; The Minimum # is %d\n&quot;,Min);</pre><p>Solution 5</p><pre>sum=a0;<br>for (i=1;i&lt;=n;i++) {</pre><pre>    element = a0 + d* i;<br>    sum += element;<br>    printf(&quot;%d &quot;, element);<br>    <br>} <br>printf(&quot; The sum  is %d\n&quot;,sum);</pre><p>Solution 6</p><pre>is_devided_by_3 = 0;<br>for (i=3, k = 1; i&lt;=n; i=i+3, k++) {</pre><pre>if (i == n) {<br>        is_devided_by_3 = 1;<br>        printf(&quot; %d divided by 3 = %d\n&quot;, n, k);<br>    }<br>    <br>} <br>if (is_devided_by_3 == 0) {<br>    printf(&quot; %d is not divided by 3\n&quot;, n);</pre><pre>}</pre><p>Or without using k inside the for loop declaration:</p><pre>int k = 1;<br>for (i=3; i&lt;=n; i=i+3) {<br>    <br>    if (i == n) {<br>        is_devided_by_3 = 1;<br>        printf(&quot; %d divided by 3 = %d\n&quot;, n, k);<br>    }<br>    k+=1; <br>}</pre><p>Next Chapter --&gt; <a href="https://naomi-fridman.medium.com/c-code-beginners-practice-9c4204925feb">Exercise on nested For loops</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4933a368d966" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine learning — מה שמנהל צריך לדעת]]></title>
            <link>https://naomi-fridman.medium.com/machine-learning-%D7%9E%D7%94-%D7%A9%D7%9E%D7%A0%D7%94%D7%9C-%D7%A6%D7%A8%D7%99%D7%9A-%D7%9C%D7%93%D7%A2%D7%AA-84573b6a4645?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/84573b6a4645</guid>
            <category><![CDATA[עקומת-רוק]]></category>
            <category><![CDATA[קרוס-וולידציה]]></category>
            <category><![CDATA[אוברפיט]]></category>
            <category><![CDATA[מדריך-למנהל]]></category>
            <category><![CDATA[למידת-מכונה]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Sun, 28 Mar 2021 08:03:10 GMT</pubDate>
            <atom:updated>2021-04-04T23:37:11.092Z</atom:updated>
            <content:encoded><![CDATA[<h3>Machine learning מה שמנהל צריך לדעת</h3><h4>או — איך לקרוא תוצאות של מודל ואיך לאמת אותו</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*jRNUwfbIgTO7OkJyiLS4TQ.png" /></figure><figure><img alt="כאשר מוצג מודל פתרון לבעיה, השאלות העיקריות אותן צריך לשאול המנהל, הן:
 עד כמה המודל אמין לשימוש על האוכלוסייה הכללית ?" src="https://cdn-images-1.medium.com/max/865/1*RyHQZQGg2uoAnrgGaaNzmw.png" /></figure><figure><img alt="עד כמה איכותי ומדוייק, יהיה המודל על האוכלוסייה הכללית ?" src="https://cdn-images-1.medium.com/max/847/1*iC6G6V7rP8_aSX8etjU2kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*uvojndiu8--PPMIxQyEWmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*8JF5BeMCFDj9v1x_OeDkhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*TvRRP4HQJIycCX_eBH7-bw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*6WFcgzCE8mu6_6i98EQRVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*KG0QiqKTh-sW5w12SgFgdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*eVAR2K_1ED_V-_dLuUgZ1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*p5HOJDwbw3gdQVP5KuOCmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*01hUzD0_iQ4Nn_qOuby5TA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*NIoAcQaz04L4F0sDrSnCfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qAjqYygxU8xtUW0v" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*GidM4wSIVRP_eFTkCOCUkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*LCUbGVu8uCfVQrisj9q6Sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*R42A54iKKmwxAK2Z8uHacQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*S3MD2pM7WDnGsRfLAwTIrQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*R3evmY4fRWSMDc_fL_osXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*iLNKu17RdVaAO6pWbKBfUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g6EXb1IE8ZKBJl5k" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*1QVXfDTb7dq9P9W4tBJ6Eg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*e6ZTMV_qp5wYMeU1Mtbdpw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*hB3CA0eilCLF1XZXp71orw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*BEM44FRhYdwTIJsG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*rrujKTYtm719PcjY1k1vQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*BVApmzrBXE-nRa8yacrntw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*NkkDyGsorrX1Rfg4" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*43W4X4eNo432fRYYpLF09g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*P2mQI2Yfrqbry43m0_F8Aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*NMJFcVzfp-i5vpLCJwM--w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*vGt27JFH0uMaN8-t8UvFTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*rOp-orPvaJSGQ9L8XsqlZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/0*Y118ZUw3Dfd_dC4k" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*fajt7mUjN4cRr54v2o1vRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/0*yCLrLee3XsJ5_2Wl" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*wvLwUbkvv3g4FDhPOOBl4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*YJ-4CgekFKN57o2RTMlGsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*qfuNFm4_9pGV74UMne3eWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*ttukDXsdmdJgH_E8_0QT6g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*hBiKr0jq7Gc2S0f4A5BNcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*Ht-cjwvFUfzTKC4NXpDLWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*TT04SMzlIuaxMGGZ-GBRtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*WRdLxWr0vIV8qZ041COZFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*nXEWuBBFvsIEHKsjE9UjKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/0*4q0-Vv10tN9R7NZm" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*pcxekyCAau5cHJFU30FNgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*PYkDicJtuUn_dXI7590oBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*q5IiYoh6iJG-le43lG0YbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*JvEpLsHKsy4cd_L1WWnpZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*GfiAvyfjyHgwtjoZrX_Hig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*LvXIuCLIefJ4dqbM8NIvow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*JNc1ycc1exYkciOJkhliuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*fu_L92rb_lnnBiGTwOixpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*3-6GVjiQ97dKeOc1kJtVfw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*ExK4FhjFd3pKjDhXtUI8gg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*CbVO4QJeaEP1Xljw7gylwQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*as76lI6UlFSOlfYowOzEYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*dJvri6uRzjsnjLGGIMRpxw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/0*szk1qML1n__FtrQL" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*YGw9u7yN18MyrkmtbWmhww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Yny5CSL5U1CuM-N8N6rdqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H3_V_HQ5Ntvz5-vR" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*54I12M3YyYSigv-h3B3ujA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*crDUHsFp4WB0VBzqGvMz7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*khj_9_ScGKSiNnB3MVSOYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*Xm9qJ6nTJzN74x-DdU514A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*CSv0BqckVpwhaJV-pUG7ow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*hHFXaXQq3nip3MiBVoA9qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*QnXJ0zkTrXIn9s5QRmTTkA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84573b6a4645" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Segmentation Using Color Spaces]]></title>
            <link>https://naomi-fridman.medium.com/image-segmentation-using-color-spaces-11a7ef75653?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/11a7ef75653</guid>
            <category><![CDATA[image-segmentation]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[segmentation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[signal]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Mon, 28 Sep 2020 22:03:26 GMT</pubDate>
            <atom:updated>2020-09-29T09:48:45.955Z</atom:updated>
            <content:encoded><![CDATA[<p>In many deep learning imaging projects, we are required to extract all kind of parts of the image. In medical imaging, for example, it’s very common to have marking as name, date and meta data on the images. Here I use example from my last project, were we had to extract signal data from graph images.</p><p>Very interesting, where is the code ?<a href="https://github.com/naomifridman/fetus_stress_detection_FHR_UC/blob/master/exctract_signal_from_img.ipynb">https://github.com/naomifridman/fetus_stress_detection_FHR_UC/blob/master/exctract_signal_from_img.ipynb</a></p><p>In this post, we will extract the FHR, signal’s from their images. Googling this problem, will give you the popular <a href="https://stackoverflow.com/questions/30331944/finding-red-color-in-image-using-python-opencv">stackoverflow</a>, with shv boundaries. But how to find them is not clear. Here we focus on how to analyze your specific image set, and find the suitable boundaries for your image set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*JQKcS9N3JIHgYUEoYdGjCw.jpeg" /><figcaption>CTG FHT TOCO example from <a href="http://www.tthdigital.com.au/wp-content/uploads/Maternity-%E2%80%93-FetaLink-Manual.pdf">here</a></figcaption></figure><h3>Visualizing image Color Space</h3><p>First lest visualize image in RGB color space</p><figure><img alt="RGB color space of the FHR signal in CTG" src="https://cdn-images-1.medium.com/max/467/1*q9iKiwsbK-SJZOe6tMUwAA.png" /><figcaption>RGB color space of the FHR signal in CTG</figcaption></figure><p>If we had only few pixels in the desired color we want to filter, we could have filtered it by calculating Euclidean distance from a set of pixels. But in this case, as in most cases, color space is quit reach. So we seek solution in the HSV color space.</p><figure><img alt="Visualizing image in HSV Color Space" src="https://cdn-images-1.medium.com/max/582/1*PJm_cdjQlRXz1CsZU73IUg.png" /><figcaption>Visualizing image in HSV Color Space</figcaption></figure><p>Our goal is to find bounding box of the signal’s color’s. To make it easier, lets focus on the color we want to extract, and crop ROI part of the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rjMqRk1_B3Cp0KeiFLVt3Q.png" /><figcaption>FHR signal only</figcaption></figure><p>HSV visualization of the cropped image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*c2ew7CJny3AtQhNMp1kMUg.png" /></figure><p>To find the bounding box of the colors we want to extract, lets project the 3d color spacing on 2d:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*h2PNhsptCiSpRWNANTzUEg.png" /></figure><p>We can see that Hue can be bounded between 80–100 to 120</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*5jxfVCG1MyhkmzmXQPCTfQ.png" /></figure><p>we can try bound Saturation to be &gt; 50. Applying boundaries, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*-tC21QgNT1D61Uqqqp77KQ.png" /></figure><p>Full code of the analysis is in the git. The main function, is listed below:</p><pre>def exctract_blue_signal(im):<br> hsv_im = cv2.cvtColor(im, cv2.COLOR_RGB2HSV)<br> lower_blue = np.array([78, 50, 100])<br> upper_blue = np.array([100, 255, 230])<br> mask = cv2.inRange(hsv_im, lower_blue, upper_blue)<br> res = cv2.bitwise_and(im,im,mask)<br> mask3 = np.repeat(mask[:,:,np.newaxis], 3, axis=2)/255<br> masked_im = im*mask3/255.<br> return mask, masked_im</pre><p>Calling the function, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fviEa8ptlLA0Ri_AXITAvA.png" /></figure><p>Another example, with its HSV visualization:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oDqapUan2EGupobBtqbxA.png" /><figcaption>FHR and TOCO signals from <a href="https://neoreviews.aappublications.org/content/21/3/e203/tab-figures-data">here</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*wLNJZHDTs2ZW8w-fUdqYTQ.png" /></figure><p>According to the HSV visualization, we can see that we will need 2 bounding boxes to filter the red signal. Analyzing the signal’s image, as we did before, summarize to the following function:</p><pre>def exctract_red_signal(im):<br>    <br>    hsv_im = cv2.cvtColor(im, cv2.COLOR_RGB2HSV)<br>    lower_red = np.array([160, 160, 200])<br>    upper_red = np.array([180, 255, 255])<br>    <br>    mask0 = cv2.inRange(hsv_im, lower_red, upper_red)<br>    <br>    lower_red = np.array([0, 200, 200])<br>    upper_red = np.array([20, 255, 255])<br>    <br>    mask1 = cv2.inRange(hsv_im, lower_red, upper_red)<br>    mask = mask0+mask1<br>    <br>    res = cv2.bitwise_and(im,im,mask)<br>    mask3 = np.repeat(mask[:,:,np.newaxis], 3, axis=2)/255<br>    <br>    masked_im = im*mask3/255.</pre><pre>return mask, masked_im</pre><p>Applying this function on the signal’s image, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*Jm9XMQ4vi9WJ1g5lQ4hU-w.png" /></figure><p>Some small color space is still missing, continue analyze :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11a7ef75653" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning with Graph data — Basics]]></title>
            <link>https://naomi-fridman.medium.com/learning-with-graph-data-basics-6f3b7c10b9b5?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f3b7c10b9b5</guid>
            <category><![CDATA[networkx]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[graph]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Sun, 03 May 2020 22:05:31 GMT</pubDate>
            <atom:updated>2020-05-04T15:43:15.219Z</atom:updated>
            <content:encoded><![CDATA[<h3>Learning with Graph data — Basics</h3><h3>Networkx Python Graph package</h3><p><a href="https://networkx.github.io/">Networkx </a>is a an open source python package, that handles graph data structure. Networkx contain few graph algorithms, and there are other packages that implement deep learning algorithms, using networkx data structure.</p><h3>Create a Graph with locations and weights</h3><p>There are many options to create a graph in networkx. I will show few examples. The basic “must have” is set of nodes, and a set of edges, when en edge is defined by the start-end nodes.</p><h4>Create simple Graph with locations and weights</h4><pre>import networkx as nx<br>l = [(5,7),(7,1),(7,2),(1,4),(1,6)]<br>Gt=nx.Graph()<br>Gt.add_edges_from(l)<br>nx.draw(Gt, with_labels=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*7qwgJY0d5DXInUr4L0Vw7w.png" /></figure><h4>Create a Graph with locations and weights</h4><pre>import networkx as nx<br>l = [(&#39;1&#39;,&#39;2&#39;,3.),(&#39;2&#39;,&#39;3&#39;,2.5),(&#39;3&#39;,&#39;4&#39;,1.5),(&#39;3&#39;,&#39;5&#39;,4.),(&#39;1&#39;,&#39;6&#39;,5.),(&#39;6&#39;,&#39;7&#39;,2.),(&#39;6&#39;,&#39;8&#39;,3.),(&#39;9&#39;,&#39;8&#39;,5.)]<br>Gt=nx.Graph()<br>Gt.add_weighted_edges_from(l)<br>labels = nx.get_edge_attributes(Gt,&#39;weight&#39;)<br>nx.draw(Gt, with_labels=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*S_WbGf1wXEp6SSchu7DmHg.png" /></figure><p>Add node and edge to the graph. The node will have feature vector,</p><pre>feature_vector=np.array([1,7,22])<br>Gt.add_node(100,v=feature_vector, label=&#39;n1&#39;)<br>Gt.add_edge(&#39;1&#39;, 100, weight = 8)<br>nx.draw(Gt, with_labels=True)</pre><p>Force plotting of the graph, in the correct locations defined in the nodes.</p><pre>pos = nx.spring_layout(Gt)<br># Draw the graph according to node positions<br>nx.draw(Gt, pos, with_labels=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*ZoHPLvxzGs-iFJB0Ax83xQ.png" /></figure><p>Plot edge weights</p><pre># Create edge labels<br>labels = {e: str(Gt.get_edge_data(e[0], e[1])[&#39;weight&#39;]) for e in Gt.edges}<br>labels = {e: str(Gt.get_edge_data(*e)[&#39;weight&#39;]) for e in Gt.edges}<br>nx.draw_networkx_edge_labels(Gt, pos, edge_labels=labels);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*VVNkceeMMahhL7_qwxTtQg.png" /></figure><p>Code is in my git:<a href="https://github.com/naomifridman/Graph_learning"> github.com/naomifridman/Graph_learning</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f3b7c10b9b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding LSTM — Survay]]></title>
            <link>https://naomi-fridman.medium.com/understanding-lstm-survay-eca82d1054d5?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/eca82d1054d5</guid>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Tue, 11 Feb 2020 22:45:33 GMT</pubDate>
            <atom:updated>2020-03-24T22:38:41.423Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding LSTM — Resources</h3><h3>Fun introduction</h3><p>To get general idea, its fun to watch the deep learning celeb you-tuber, <a href="https://youtu.be/ftMq5ps503w">Siraj raval</a>. It has nice explanation of the architecture, with full demonstration of the code on a simple stock market example.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FftMq5ps503w%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DftMq5ps503w&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FftMq5ps503w%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ee7a8deca65796b7223c421120489ce/href">https://medium.com/media/6ee7a8deca65796b7223c421120489ce/href</a></iframe><h3>Recurrent Neural networks</h3><p>Recurrent neural network, RNN, are the basic concept of networks with memory, which are capable of learning sequential data. LSTM are specific (more complex) kind of RNN, and its the one most robust model.</p><p>This popular post: <a href="https://colah.github.io/posts/2015-08-Understanding-LSTMs/">Understanding LSTM Networks — <em>August 27, 2015</em></a><em>, </em>is a good starting point in understanding the building blocks of RNN architecture.</p><p><a href="https://colah.github.io/posts/2015-08-Understanding-LSTMs/">Understanding LSTM Networks</a></p><p>Very good explanation of the RNN concept ,architecture and limitations. A short summary is that RNN have a “fixed” memory structure, that enables the model to “remember” only what was designed in advance.</p><p>Clear explanation of LSTM, and how they overcome the RNN “fixed” memory limitation by learning long-term dependencies. LSTM have an architecture that enables learning of what to remember.</p><h3>Stanford CS231 RNN lecture</h3><p>There are few versions of this Deep learning iconic course, my favorite is: <a href="https://youtu.be/yCC09vCHzF8">Stanford CS231n Winter 2016</a>: Lecture 10: Recurrent Neural Networks, Image Captioning, LSTM. Lecture is given by <a href="https://medium.com/@karpathy">Andrej Karpathy</a>, and i recommend his blog as well. The older posts are on <a href="http://karpathy.github.io/">git</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FyCC09vCHzF8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DyCC09vCHzF8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FyCC09vCHzF8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/59cc3d37c3aa8c7f7bfceb5aa4c80ebf/href">https://medium.com/media/59cc3d37c3aa8c7f7bfceb5aa4c80ebf/href</a></iframe><p>Lecture slides: <a href="http://cs231n.stanford.edu/slides/2019/cs231n_2019_lecture10.pdf">http://cs231n.stanford.edu/slides/2019/cs231n_2019_lecture10.pdf</a></p><p>Course syllabus: <a href="http://cs231n.stanford.edu/syllabus.html">http://cs231n.stanford.edu/syllabus.html</a></p><h3>LSTM examples in different fields</h3><h4>Character-level language models</h4><p>Recommended article “<a href="http://karpathy.github.io/2015/05/21/rnn-effectiveness/">The Unreasonable Effectiveness of Recurrent Neural Networks</a>” from <a href="http://karpathy.github.io/">Andrej Karpathy blog</a>. Those who like to understand concepts by writing codes (like me :), will enjoy this article that includes complete code to generate text by predicting the next character.</p><h4>Time series classification</h4><p>Clear well explained post, “<a href="https://www.analyticsvidhya.com/blog/2019/01/introduction-time-series-classification/">A Hands-On Introduction to Time Series Classification (with Python Code)</a>”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eca82d1054d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Learning with docker container from NGC — Nvidia GPU Cloud]]></title>
            <link>https://medium.com/data-science/deep-learning-with-docker-container-from-ngc-nvidia-gpu-cloud-58d6d302e4b2?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/58d6d302e4b2</guid>
            <category><![CDATA[cuda]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[nvidia-docker]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Wed, 08 Jan 2020 12:24:48 GMT</pubDate>
            <atom:updated>2021-05-18T17:19:59.735Z</atom:updated>
            <content:encoded><![CDATA[<h3>Deep Learning with docker container from NGC — Nvidia GPU Cloud</h3><h4>With a basic copy-paste how-to guide for working with dockers</h4><figure><img alt="https://pixabay.com/photos/container-port-loading-stacked-3118783/" src="https://cdn-images-1.medium.com/max/640/1*RkrWqhLUhr0iNpzncytP9w.jpeg" /><figcaption>docker containers :) image from <a href="https://pixabay.com/photos/container-port-loading-stacked-3118783/">pixabay</a></figcaption></figure><p>No more sweating over the installation of Deep Learning environment. No more fighting with Cuda versions and GCC compilers. Welcome to the docker era. All you need is a Unix system with updated Cuda drivers. All you need is to download a docker from NGC cloud that contains the environment you need with all the Cuda code.</p><p>Actually, after writing this post, I find myself using it more and more. Since my main work is in Deep Learning on medical (highly secured) data, I use dockers a lot. When you must work on a server without the internet (yes, this is painful not to have <a href="https://stackoverflow.com/">StackOverflow</a>) a docker is your savior :). You prepare your working environment in normal surroundings then you/system admin, migrate it to the server. An interesting advantage that I am exploring now is to enrich your environment with git repositories, manuals, etc. I will update here the methods I find.</p><p>Here we will use Python 3 and TensorFlow 1.9, but there are dockers with Pytorch, Caffe, trained model, and more.</p><figure><img alt="https://ngc.nvidia.com/" src="https://cdn-images-1.medium.com/max/783/1*jdo1AIB0HzNBLnQYi1tryw.png" /><figcaption><a href="https://ngc.nvidia.com/">Nvidia cloud</a> image from Nvidia cloud website</figcaption></figure><h3>Get yourself Nvidia Docker</h3><p>Go to <a href="https://ngc.nvidia.com/catalog/all">https://ngc.nvidia.com/catalog/all</a>. Choose the Container tab and view all available containers. I chose the TensorFlow container:</p><figure><img alt="https://ngc.nvidia.com/" src="https://cdn-images-1.medium.com/max/343/1*ON9umkShiIsoD5-S-KDBTg.png" /><figcaption><a href="https://ngc.nvidia.com/">TensorFlow container on Nvidia cloud</a></figcaption></figure><p>You can use it directly from the cloud, with: nvcr.io/nvidia/tensorflow: 19.12-tf2-py3 a TensorFlow2 docker. Or download it, after you created an account and logged in.</p><p>To download a TensorFlow2 docker, use the pull command:</p><pre>docker pull nvcr.io/nvidia/tensorflow:20.10-tf2-py3</pre><p>It takes some time to download the docker.</p><h3>Start docker container</h3><p>List all available local docker images</p><pre>$ sudo docker images</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iukWQY0Fc2VgTATsGE_sCg.png" /></figure><pre><strong>docker run --rm -it --runtime=nvidia --net=host -v &lt;local dir&gt;:&lt;destination dir&gt; &lt;Image id&gt;</strong></pre><p>For example, for a local docker, use:</p><pre><strong>docker run --rm -it --runtime=nvidia --net=host -v /my_server_dir/:/naomi </strong>989143febb16</pre><p>Or use a docker from Nvidia cloud:</p><pre>docker run --gpus all -it --rm -v local_dir:container_dir nvcr.io/nvidia/tensorflow:19.12-tf2-py3</pre><p>Where:</p><ul><li>-it means run in interactive mode</li><li>--rm will delete the container when finished</li><li>-v is the mounting directory</li><li>local_dir is the directory or file from your host system (absolute path) that you want to access from inside your container. container_dir is the target directory when you are inside your container. For example,</li></ul><p>For example, the local_dir in the following path is /home/jsmith/data/mnist and the target directory is: /data/mnist .</p><pre>-v /home/jsmith/data/mnist:/data/mnist</pre><p>Example taken from: <a href="https://ngc.nvidia.com/catalog/containers/nvidia:tensorflow">https://ngc.nvidia.com/catalog/containers/nvidia:tensorflow</a></p><h3>Stop a docker container</h3><pre># list running dockers:<br>$ docker ps</pre><pre># Find the docker container id, then run:</pre><pre>docker kill &lt;container id&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zi2NM8-WNKSnH3rXmFFrjA.png" /></figure><h3>Attach to a running docker container</h3><p>When you want to run a command in the docker, from the outside, you use exec, which allow you to tell the running docker, to run a specific command. When, for example, you lose the command line window that manages the docker, you can use exec to run command line environment, in the docker. This way, you attach to the running docker container. For example, use the following command to create a shell inside the docker container.</p><pre><strong>docker exec -it &lt;container id&gt; /bin/bash</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*6YEfFNZHv01pHvm4mB80RQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*dTTHhldWsHAE2dpLLVKCfw.png" /></figure><h3>Add Packages and data into the Docker container</h3><p>When you are “inside” the docker container, you are in linux cmd space. You can install python packages with pip for example, and you can also upload data. This option is very useful for people working on secured data, on servers without internet, as myself in health industry. This way you prepare yourself everything you need, then commit it and transfer it to your closed server.</p><p>If you use Nvidia docker container, it comes without jupyter. You can Install it with:</p><pre><strong>pip install jupyter</strong></pre><h3>Run Jupyter notebook on docker container</h3><p>If you are in a gui environment, like RDP, you can run jupyter notebook easily, just do as the following. If you have only cmd on the server, as in mobaxterm, few more steps are needed, and they are specified few sections ahead.</p><p>Start note book with the following command:</p><pre><strong>jupyter notebook --ip 0.0.0.0 --allow-root</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbB0OryN7Hyx7k5JQ9kU7w.png" /></figure><p>In your browser, type: <a href="http://192.168.15.20/">http://&lt;server ip&gt;</a>:8888/?token=&lt;token&gt; . In our case:</p><pre><a href="http://192.168.15.20/">http://100.200.15.20</a>:8888/?token=2a0630188ca7bc5b99d2c5b7923e2a2ebe391bc15a4bc3f1</pre><p>Copy the token that is given in the cmd.</p><p>If port 8888 is taken, or there is other reason you need to bind port, ise:</p><pre><strong>jupyter-notebook --ip 0.0.0.0 --allow-root --port 5080</strong></pre><p>Then use address:</p><pre><a href="http://192.168.15.20/">http://100.200.15.20</a>:<strong>5080</strong>/?token=2a0630188ca7bc5b99d2c5b7923e2a2ebe391bc15a4bc3f1</pre><p>or</p><pre><a href="http://192.168.15.20/">http://</a><strong>0.0.0.0</strong>:<strong>5080</strong>/?token=2a0630188ca7bc5b99d2c5b7923e2a2ebe391bc15a4bc3f1</pre><p>It’s convenient to use the notebook for installation of packages and other back-end staff. Just use ! at the beginning of command line, and run each command line in a separate cell. For example:</p><pre>! pip install keras</pre><p>To save your installations in the docker image, don&#39;t forget to commit the docker.</p><h3>Commit a docker</h3><p>Commit a docker, will create a new docker with all your installations.</p><pre>docker commit &lt;docker container id&gt; &lt;new docker name&gt;:&lt;docker tag&gt;</pre><p>For example, committing a docker with the following command:</p><pre>docker commit   9571cb71d812 naomi/brats:version2</pre><p>Will create a docker image that will look like this when running `docker images`:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M-OF8xK1hun_SPxHVoT3dg.png" /></figure><h3>Docker — Basic Summary</h3><p>What’s an article worth without some copy-paste :)</p><pre><strong># run<br>docker run --rm -it --runtime=nvidia --net=host -v &lt;local dir&gt;:&lt;destination dir&gt; &lt;docker Image id&gt;</strong></pre><pre><strong># list available dockers<br>docker images</strong></pre><pre><strong># list running docker<br>docker ps</strong></pre><pre><strong># attach to a running docker<br>docker exec -it &lt;container id&gt; /bin/bash</strong></pre><pre><strong># run notebook<br>jupyter notebook --ip 0.0.0.0 --allow-root</strong></pre><pre><strong># commit a docker<br>docker commit &lt;docker container id&gt; &lt;new docker name&gt;</strong></pre><p>More explanations on using dockers and the meaning of each flag can be found here: <a href="https://ngc.nvidia.com/catalog/containers/nvidia:tensorflow">https://ngc.nvidia.com/catalog/containers/nvidia:tensorflow</a></p><p>Following are few sections with less common, but needed, scenarios.</p><h3>Running Jupyter notebook from Mobaxterm</h3><p>The idea is run the jupyter command on cmd, and open the notebook at your local machine. This requires ssh tunneling, which described below:</p><p><strong>Windows side</strong> First, Generate ssh key: <a href="https://phoenixnap.com/kb/generate-ssh-key-windows-10">https://phoenixnap.com/kb/generate-ssh-key-windows-10</a>, this process will create a file on your local computer.</p><p><strong>Mobaxterm side</strong> Open tunneling menu to define your tunneling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*w9tfF2VLBTlQatsjF7GeeQ.png" /><figcaption>Mobaxterm ssh tunneling</figcaption></figure><p>Assume your remote server is 52.522.52.522, your user name is naomi , and you chose 1200 as the port (you can choose any antaken number), fill the following, and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ukeI9WuU3yH0a3CGMf-Xhg.png" /></figure><p>Save and add the ssh key you created before, here in the key icon:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*SjEQbJxuhqHZQrN5t2FNMA.png" /><figcaption>adding ssh key for tunneling and ssh session</figcaption></figure><p><strong>Window side</strong> Run the following command as an administrator in a Powershell</p><pre><strong>ssh -NL 1200:localhost:1200 naomi@</strong>52.522.52.522</pre><p><strong>Mobaxterm side </strong>Run the following command in Mobaxterm cmd window:</p><pre>jupyter notebook — no-browser — port 1200</pre><p>Copy the address you get from the output, to a chrome or similar, at your local windows machine, and you can work in the notebook:</p><pre><a href="http://127.0.0.1:1250/?token=36401f7dada8b4cb5eb2d15b70ac3e4963633e7dd5b922d1">http://127.0.0.1:1200/?token=36401f7dada8b4cb5eb2d15b70ac3e4963633e7dd5b922d1</a></pre><h3>Reconnect to a running Jupyter notebook</h3><p>Deep learning training usually takes a long time. So in most cases, when working on a remote server, the connection is closed and the token to the notebook is lost. To find the token of a running notebook, do:</p><pre># use -mtime -30 to list only notebooks that started in the last 30 days.</pre><pre>find `jupyter --runtime-dir` -mtime -30 | grep nbserver | xargs cat</pre><p>You will see something like:</p><pre>...<br>&lt;body&gt;</pre><pre>&lt;p&gt;<br>    This page should redirect you to Jupyter Notebook. If it doesn&#39;t,<br>    &lt;a href=&quot;<a href="http://0.0.0.0:8888/tree?token=7caaccce4fb4e670d9053b67c773e93c4a6ceb128fde2f56">http://0.0.0.0:8888/tree?token=7caaccce4fb4e670d9053b67c773e93c4a6ceb128fde2f56</a>&quot;&gt;click here to go to Jupyter&lt;/a&gt;.<br>&lt;/p&gt;<br>...</pre><p>Just copy the address (changing 0.0.0.0 to your servers IP, or localhost) to your browser, to reopen the running notebook.</p><h3>User issues</h3><p>In the docker container, you are the king of your kingdom, you are the root user, which I guess is needed for installations. The files you write get root ownership on the disk, even if you don’t have the root password. Deleting a file you created in a container can be done only with a root password or from a docker. I haven&#39;t figured it out yet. Any insights will be appreciated.</p><h3>Install Docker Engine</h3><p>If you need install fresh docker engine, follow the instructions <a href="https://docs.docker.com/engine/install/ubuntu/">here</a>. For convenience I will add short summary of the recommended method.</p><h4>Install using the repository</h4><p>For host machine: focal Ubuntu 20.04 LTS, Release: 20.04. x86_64 / amd64.</p><pre># Set up the repository<br>$ sudo apt-get update<br>$ sudo apt-get install \<br>    apt-transport-https \<br>    ca-certificates \<br>    curl \<br>    gnupg-agent \<br>    software-properties-common</pre><pre># Add Docker’s official GPG key:<br>$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -</pre><pre># set up the <strong>stable</strong> repository<br>$ sudo add-apt-repository \<br>   &quot;deb [arch=amd64] https://download.docker.com/linux/ubuntu \<br>   $(lsb_release -cs) \<br>   stable&quot;</pre><h4>Install Docker Engine</h4><pre>$ sudo apt-get update<br>$ sudo apt-get install docker-ce docker-ce-cli containerd.io</pre><p>Start docker daemon</p><pre>sudo dockerd</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58d6d302e4b2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/deep-learning-with-docker-container-from-ngc-nvidia-gpu-cloud-58d6d302e4b2">Deep Learning with docker container from NGC — Nvidia GPU Cloud</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi class Image Segmentation]]></title>
            <link>https://naomi-fridman.medium.com/multi-class-image-segmentation-a5cc671e647a?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5cc671e647a</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[keras]]></category>
            <category><![CDATA[multi-classifications]]></category>
            <category><![CDATA[unet]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Thu, 14 Nov 2019 21:32:50 GMT</pubDate>
            <atom:updated>2022-01-11T22:05:57.307Z</atom:updated>
            <content:encoded><![CDATA[<h3>U-Net Segmentation <strong>BraTS 2019</strong></h3><h3>BraTS brain tumors segmentation challenge</h3><p>BraTS is a challenge of segmentation of brain tumors in multimodal magnetic resonance imaging (MRI) scans. <strong>BraTS 2019</strong> utilizes multi-institutional pre-operative MRI scans and <strong>focuses on the segmentation of</strong> intrinsically heterogeneous (in appearance, shape, and histology) <strong>brain tumors</strong>, namely gliomas.</p><p>The group article of BRATS challenge, including this work, can be found here: <a href="https://www.researchgate.net/publication/346716362_Identifying_the_Best_Machine_Learning_Algorithms_for_Brain_Tumor_Segmentation_Progression_Assessment_and_Overall_Survival_Prediction_in_the_BRATS_Challenge/citations?source=responses-----3ed4ee2be40e---------------------respond_sidebar-----------">Machine_Learning_Algorithms_for_Brain_Tumor_Segmentation…</a></p><figure><img alt="Brain tumor multi class unet segmentation" src="https://cdn-images-1.medium.com/max/1024/1*40ZzbDi-2pckLtXKSdvJkQ.png" /><figcaption>Ground truth label and model predictions</figcaption></figure><h3>Loading Dicom MRI data</h3><p>The data contains 259 Train images with 4 label types: And 76 validation images. Images are MRI dicom files with 4 channels: ‘FLAIR’, ‘T1’,’T1CE’, ‘T2’. SimpleITK python package is used to read, write and convert MRI data to python. For convenience, I change label 4 to 3. Train data was split,with 0.2 test data. Label are not equal, distribution is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*otjw8fn4Pv1JpjCUzJJ51A.png" /><figcaption>Tumor segmentation Label types</figcaption></figure><p>From viewing few segmented images, we can predict that the distinction between labels, will be the hardest part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OomLkxgeAws0URagaFWLWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oFSlI9xkmmAYndesAVcP3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mCxV-Yy1RIJlvywWaPYhEA.png" /></figure><h3>UNET Architecture and Training</h3><p>The <a href="https://arxiv.org/abs/1505.04597"><em>UNET</em></a><em> </em>was developed by Olaf Ronneberger et al. for Bio Medical Image Segmentation. The original network won the ISBI cell tracking challenge 2015, by a large margin, and became since the state-of-the-art deep learning tool for image segmentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*OkUrpDD6I0FpugA_bbYBJQ.png" /></figure><p>The original network was built for 512x512x3 microscopy images, here its modified to an image shape of 240x240x4.</p><pre>inputs = Input(input_size)<br> <br> conv1 = Conv2D(64, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(inputs)<br> conv1 = Conv2D(64, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv1)<br> pool1 = MaxPooling2D(pool_size=(2, 2))(conv1)</pre><pre> conv2 = Conv2D(128, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(pool1)<br> conv2 = Conv2D(128, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv2)<br> pool2 = MaxPooling2D(pool_size=(2, 2))(conv2)</pre><pre> conv3 = Conv2D(256, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(pool2)<br> conv3 = Conv2D(256, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv3)<br> pool3 = MaxPooling2D(pool_size=(2, 2))(conv3)</pre><pre> conv4 = Conv2D(512, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(pool3)<br> conv4 = Conv2D(512, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv4)<br> drop4 = Dropout(dropout)(conv4)<br> pool4 = MaxPooling2D(pool_size=(2, 2))(drop4)</pre><pre>conv5 = Conv2D(1024, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(pool4)<br> conv5 = Conv2D(1024, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv5)<br> drop5 = Dropout(dropout)(conv5)</pre><pre>up6 = Conv2D(512, 2, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(UpSampling2D(size = (2,2))(drop5))<br> merge6 = concatenate([drop4,up6], axis = 3)<br> conv6 = Conv2D(512, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(merge6)<br> conv6 = Conv2D(512, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv6)</pre><pre>up7 = Conv2D(256, 2, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(UpSampling2D(size = (2,2))(conv6))<br> merge7 = concatenate([conv3,up7], axis = 3)<br> conv7 = Conv2D(256, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(merge7)<br> conv7 = Conv2D(256, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv7)</pre><pre>up8 = Conv2D(128, 2, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(UpSampling2D(size = (2,2))(conv7))<br> merge8 = concatenate([conv2,up8], axis = 3)<br> conv8 = Conv2D(128, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(merge8)<br> conv8 = Conv2D(128, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv8)</pre><pre>up9 = Conv2D(64, 2, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(UpSampling2D(size = (2,2))(conv8))<br> merge9 = concatenate([conv1,up9], axis = 3)<br> conv9 = Conv2D(64, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(merge9)<br> conv9 = Conv2D(64, 3, activation = ‘relu’, padding = ‘same’, kernel_initializer = hn)(conv9)<br> <br> conv10 = Conv2D(IMG_CHANNELS, (1,1), activation = ‘softmax’)(conv9)<br> <br> model = Model(inputs = inputs, outputs = conv10)</pre><p>To compensate label imbalance, train batches where constructed in the following way: half of the batch are randomly selected planes from few randomly selected images. And the other half, are planes that include the “rare” labels, 1 and 3. For test images, random planes where chosen.</p><p>Training:</p><pre>history = model.fit_generator(gen_train_fast,<br>                                        validation_data = gen_test_im, validation_steps=1,<br>                                              steps_per_epoch=30,<br>                              epochs=100,<br>                    callbacks=[earlystopper, checkpointer, reduce_lr])</pre><p>Model learned up to the 11 epoch, and reached:</p><pre>loss: 0.0519 - accuracy: 0.9819 <br>val_loss: 0.0323 - val_accuracy: 0.9876</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WvCLKLhJBhwxcyM-BTJ9Fw.png" /></figure><p>Lets view few predictions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tkvQhRATW6XZTWWOF3d_aA.png" /></figure><p>Collective article, that includes this work: <a href="https://www.researchgate.net/publication/346716362_Identifying_the_Best_Machine_Learning_Algorithms_for_Brain_Tumor_Segmentation_Progression_Assessment_and_Overall_Survival_Prediction_in_the_BRATS_Challenge/citations?source=responses-----3ed4ee2be40e---------------------respond_sidebar-----------">https://www.researchgate.net/publication/346716362_Identifying_the_Best_Machine_Learning_Algorithms_for_Brain_Tumor_Segmentation_Progression_Assessment_and_Overall_Survival_Prediction_in_the_BRATS_Challenge</a></p><p>Code in Github: <a href="https://github.com/naomifridman/Unet_Brain_tumor_segmentation">https://github.com/naomifridman/Unet_Brain_tumor_segmentation</a></p><p>A lot more can be done, mainly in augmentation and loss function.</p><p>Please don’t hesitate to write remarks, question and ideas.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5cc671e647a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic window tools for installations]]></title>
            <link>https://naomi-fridman.medium.com/basic-window-tools-for-installations-cbd3696d80c8?source=rss-f2f4a8de7de5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbd3696d80c8</guid>
            <category><![CDATA[enviornment]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[environment-variables]]></category>
            <category><![CDATA[cmd]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Naomi Fridman]]></dc:creator>
            <pubDate>Thu, 24 Jan 2019 19:06:13 GMT</pubDate>
            <atom:updated>2019-01-24T23:14:52.427Z</atom:updated>
            <content:encoded><![CDATA[<p>How to add and edit environment variable and use a command prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*13GPkfIWv6_Dpm3cd-VESA.jpeg" /><figcaption>Windows utilities needed for Spark installation</figcaption></figure><h3>Windows utilities needed for Spark installation</h3><p>Many windows users, are used to install staff only with windows executable. So, only next,next … is needed. But when you need to install things like python, anaconda or spark, you need some basic windows abilities. This is a short simple guide for the basic operation needed in Spark installation and many other installations as well.</p><p>The article: <a href="https://medium.com/@naomi.fridman/install-pyspark-to-run-on-jupyter-notebook-on-windows-4ec2009de21f">install-pyspark-to-run-on-jupyter-notebook-on-windows</a></p><h3>Manage Environment variables</h3><p>Environment variables, are variables that are kept in the operating system, and different software’s can use their value. They hold the value of all kind of needed defaults, and location of different software packages.</p><p>To add or edit system variable, type env in search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1-JwB3D9E6rEx6b8asL-Tw.png" /><figcaption>type env in search.</figcaption></figure><p>Choose `Environment variables` from `Advanced` tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*E33Hg03e99aQeOLR_yHOnA.png" /><figcaption>Choose `Environment variables` from `Advanced` tab</figcaption></figure><p>Add new system variable,or edit the existing ones. If you have the (bad:) habit to work as system administrator, you may need to edit the System’s environment variable, not only the User’s System Variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KD8cIEgjooEuwwexDXW_w.jpeg" /></figure><h3>Manage Path variable</h3><p>Path variable holds collection of locations, path’s, to binary (executable) softwares. Path variable has its own special edit dialog, allowing you to add new locations, or edit the old ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DQ19aa2-vPwP29LcwVFDZw.png" /><figcaption>Manage Path variable</figcaption></figure><p>Edit or add each location needed to Path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zm0OmiZAS_TZYu4CWIYUcA.png" /></figure><h3>Command prompt — cmd</h3><p>Command prompt is command line window of windows. You can basically do here everything you do with window gui (graphical user interface),like file explorer, start menu and soon. You can move, create and delete files, run programs, etc. To open a command prompt, type cmd in search menu. You can also open it as administrator, and sometime it&#39;s required to have administrator permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QqFkcmjXKQBd08V7DA8vpw.jpeg" /><figcaption>Command prompt — cmd</figcaption></figure><h4>Few useful command line commands</h4><ul><li>cd C:\spark — change directory, .. is to go up one dir.</li><li>mv — move file from place to place, basically cut and paste.</li><li>cp — Copy paste file</li><li>pwd — type your current directory</li><li>set — output environment variables and their values.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbd3696d80c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>