This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Data Augmentation Options": { | |
"block": null, | |
"gain": null, | |
"gamma": null, | |
"hflip": false, | |
"mean": null, | |
"noise_pwr": 0, | |
"prob": [1.0, 0, 0, 0, 0], | |
"rotate": 15, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env python | |
# check to see if any image in a directory has a problem | |
import argparse | |
import csv | |
from glob import glob | |
import os | |
import sys | |
import nibabel as nib |
We can't make this file beautiful and searchable because it's too large.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Filename,FiveoClockShadow,ArchedEyebrows,Attractive,BagsUnderEyes,Bald,Bangs,BigLips,BigNose,BlackHair,BlondHair,Blurry,BrownHair,BushyEyebrows,Chubby,DoubleChin,Eyeglasses,Goatee,GrayHair,HeavyMakeup,HighCheekbones,Male,MouthSlightlyOpen,Mustache,NarrowEyes,NoBeard,OvalFace,PaleSkin,PointyNose,RecedingHairline,RosyCheeks,Sideburns,Smiling,StraightHair,WavyHair,WearingEarrings,WearingHat,WearingLipstick,WearingNecklace,WearingNecktie,Young | |
1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,1,0,0,1 | |
2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1 | |
3,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1 | |
4,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,0,1,0,1,1,0,1 | |
5,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1 | |
6,0,1,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1 | |
7,1,0,1,1,0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1 | |
8,1,1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
tif_to_nii | |
command line executable to convert a directory of tif images | |
(from one image) to a nifti image stacked along a user-specified axis | |
call as: python tif_to_nii.py /path/to/tif/ /path/to/nifti | |
(append optional arguments to the call as desired) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExtendedMSELoss(nn.Module): | |
""" modified MSE loss for variance fitting """ | |
def forward(self, out:torch.Tensor, y:torch.Tensor) -> torch.Tensor: | |
yhat, s = out | |
loss = torch.mean(0.5 * (torch.exp(-s) * F.mse_loss(yhat, y, reduction='none') + s)) | |
return loss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExtendedL1Loss(nn.Module): | |
""" modified L1 loss for scale param. fitting """ | |
def forward(self, out:torch.Tensor, y:torch.Tensor) -> torch.Tensor: | |
yhat, s = out | |
loss = torch.mean((torch.exp(-s) * F.l1_loss(yhat, y, reduction='none')) + s) | |
return loss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExtendedBCELoss(nn.Module): | |
""" modified BCE loss for variance fitting """ | |
def forward(self, out:torch.Tensor, y:torch.Tensor, n_samp:int=10) -> torch.Tensor: | |
logit, sigma = out | |
dist = torch.distributions.Normal(logit, torch.exp(sigma)) | |
mc_logs = dist.rsample((n_samp,)) | |
loss = 0. | |
for mc_log in mc_logs: | |
loss += F.binary_cross_entropy_with_logits(mc_log, y) | |
loss /= n_samp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def regression_uncertainty(yhat:torch.Tensor, s:torch.Tensor, mse:bool=True) -> Tuple[torch.Tensor, torch.Tensor]: | |
""" calculate epistemic and aleatory uncertainty quantities based on whether MSE or L1 loss used """ | |
# variance over samples (dim=0), mean over channels (dim=1, after reduction by variance calculation) | |
epistemic = torch.mean(yhat.var(dim=0, unbiased=True), dim=1, keepdim=True) | |
aleatory = torch.mean(torch.exp(s), dim=0) if mse else torch.mean(2*torch.exp(s)**2, dim=0) | |
return epistemic, aleatory |