No clue on improving the F1 Scores with 3D Medical Images

username: Faraz
cooked: <p>Hello there,</p>
<p>I am working with multiclass <code>n_class=3</code> classification problem on a 3D Dataset input shape as such <code>(10,1,41,256,265)</code> <code>[batch_size, channels, depth, height, width]</code>. But I am always getting lower validation scores, here are the knows issues:</p>
<ol>
<li>The dataset is small, 41 volumes each of 51 Slice Images (each volume as a whole is input to the network).</li>
<li>The classes are unbalanced (c1 = 21 samples, c2 = 12 samples, c3 = 8 samples)</li>
<li>Dataset is a little noisy</li>
</ol>
<p>Things I have done:</p>
<ol>
<li>Assign different weights to each classes (c1 getting the lowest)</li>
<li>Histogram Equalization on images a preprocessing step.</li>
<li>Shuffling the train/val dataloader</li>
<li>Random train/val split.</li>
<li>Increasing batch size</li>
<li>Using different cost functions</li>
<li>Regularization (adding more dropout layers)</li>
<li>Reduce no of learning parameters</li>
<li>Change models (Pretrained resnet 3D to more simpler models)</li>
</ol>
<p>Things I have not done:</p>
<ol>
<li>Augmentation: I’m not exactly sure how to proceed with augmentation on Volume data, and which ones to specifically use for medical images.</li>
</ol>
<p>I am training and testing within the same iteration, this is the kind of result i’m usually getting, this is a simpler model though, with Resnet3D and Resnet (2+1)D usually the results are much worse.</p>
<p>thanks!</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/4/c412c2716677cbfd0cc79470d74b2f4bb13488d7.png" data-download-href="https://discuss.pytorch.org/uploads/default/c412c2716677cbfd0cc79470d74b2f4bb13488d7" title="Gaeb6BT"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c412c2716677cbfd0cc79470d74b2f4bb13488d7_2_689x249.png" alt="Gaeb6BT" data-base62-sha1="rYxM8gk5FqAIx0m4lHWxZ1b9QVN" width="689" height="249" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c412c2716677cbfd0cc79470d74b2f4bb13488d7_2_689x249.png, https://discuss.pytorch.org/uploads/default/optimized/3X/c/4/c412c2716677cbfd0cc79470d74b2f4bb13488d7_2_1033x373.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/c/4/c412c2716677cbfd0cc79470d74b2f4bb13488d7.png 2x" data-dominant-color="F9F7F5"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Gaeb6BT</span><span class="informations">1106×400 91.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>complete code, if someone can please have a look:</p><aside class="onebox githubgist" data-onebox-src="https://gist.github.com/farazahmeds/0bddc1e5dd5f7cc501c12c51b84fc0ea">
  <header class="source">

      <a href="https://gist.github.com/farazahmeds/0bddc1e5dd5f7cc501c12c51b84fc0ea" target="_blank" rel="noopener nofollow ugc">gist.github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://gist.github.com/farazahmeds/0bddc1e5dd5f7cc501c12c51b84fc0ea" target="_blank" rel="noopener nofollow ugc">https://gist.github.com/farazahmeds/0bddc1e5dd5f7cc501c12c51b84fc0ea</a></h4>

  <h5>mriDsetTrain.py</h5>
  <pre><code class="Python">import torch
import torch.nn as nn
import torch.optim as optim
import torch.utils
import torch.utils.data.dataset
import torch.utils.data.dataloader
from torch.optim import lr_scheduler
from torch import utils
import numpy as np
import torchvision</code></pre>
   This file has been truncated. <a href="https://gist.github.com/farazahmeds/0bddc1e5dd5f7cc501c12c51b84fc0ea" target="_blank" rel="noopener nofollow ugc">show original</a>

<p>
</p>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


username: fepegar
cooked: <aside class="quote no-group" data-username="Faraz" data-post="1" data-topic="72407">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/f/278dde/48.png" class="avatar"> Faraz:</div>
<blockquote>
<p>Things I have not done:</p>
<ol>
<li>Augmentation: I’m not exactly sure how to proceed with augmentation on Volume data, and which ones to specifically use for medical images.</li>
</ol>
</blockquote>
</aside>
<p>Hi, <a class="mention" href="/u/faraz">@Faraz</a>. You can use TorchIO for that: <a href="https://colab.research.google.com/github/fepegar/miccai-educational-challenge-2020/blob/master/Data_preprocessing_and_augmentation_using_TorchIO_a_tutorial.ipynb" class="inline-onebox" rel="noopener nofollow ugc">Google Colab</a></p>

username: Faraz
cooked: <p>Thanks Fernando, I posted this some time and right after this I ran into TorchIO and I was able to get the desired F1 scores. The problem had to do with the preprocessing of the images all along.</p>

username: fepegar
cooked: <p>Of course! We discussed <a href="https://github.com/fepegar/torchio/issues/180" rel="noopener nofollow ugc">slices visualization</a>, I remember you now. I’m glad it worked! Preprocessing is key. I discuss that in the notebook and in my submission to the MICCAI educational challenge: <a href="https://twitter.com/fepegar_/status/1312700144933130241" rel="noopener nofollow ugc">https://twitter.com/fepegar_/status/1312700144933130241</a></p>