Skip to content

Instantly share code, notes, and snippets.

🍜
moving bricks

Mingrui Jiang mingrui

🍜
moving bricks
Block or report user

Report or block mingrui

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mingrui
mingrui / coinChange.py
Last active Sep 14, 2019
coinChange.py
View coinChange.py
def coinChange(denominations, multiplicities, amounts):
if not amounts or len(amounts) == 0:
return True
if amounts[0] == 0:
return coinChange(denominations, multiplicities, amounts[1:])
for j in range(len(amounts)):
i = len(multiplicities) - 1
while i >= 0:
@mingrui
mingrui / save_new_nii.py
Created Oct 23, 2018
nifti file header and image
View save_new_nii.py
# https://bic-berkeley.github.io/psych-214-fall-2016/saving_images.html
def array_to_nii(array_3d, scan, output_path):
'''
Same affine and same header
convert mask only contains 0 and 1, so convert data type to uint8
:param array_3d:
:param scan:
:param output_path:
:return:
@mingrui
mingrui / results.md
Last active Oct 10, 2018
unknown results 10-10-2018
View results.md

(Result, number of patches predicted)

2018-03768 is Liver 穿刺 from Breast

data/unknown/2018-03768
[('TCGA_Kidney', 17), ('TCGA_Lung', 9), ('TCGA_Breast', 8), ('TCGA_Glioma', 3), ('TCGA_Uterus', 0), ('TCGA_Thyroid', 0), ('TCGA_Colorectal', 0), ('TCGA_Bladder', 0)]

2017-17894 is Spleen from Uterus

data/unknown/2017-17894
[('TCGA_Lung', 47), ('TCGA_Colorectal', 1), ('TCGA_Uterus', 0), ('TCGA_Thyroid', 0), ('TCGA_Kidney', 0), ('TCGA_Glioma', 0), ('TCGA_Breast', 0), ('TCGA_Bladder', 0)]

@mingrui
mingrui / dice.py
Last active Aug 20, 2018
calculate mri nifti segmentation dice score
View dice.py
import nibabel as nib
def test_nifti_all_labels_dice_score(seg_path, seg_file, truth_path, truth_file):
truth_uid = os.listdir(truth_path)
print(truth_uid)
dice_score = 0
for uid in truth_uid:
seg_file_path = os.path.join(seg_path, uid, seg_file)
truth_file_path = os.path.join(truth_path, uid, truth_file)
seg_nib = nib.load(seg_file_path)
@mingrui
mingrui / load_async.py
Created Aug 9, 2018
slide runner map_async load test
View load_async.py
def load_async(arg):
print('load_async')
tick = time.time()
filename, reader_location, level, reader_size, location, size = arg
slide = openslide.open_slide(filename)
region = slide.read_region(location=reader_location, level=level, size=reader_size)
# Convert to numpy array
cachedImage = np.array(region, dtype=np.uint8)
@mingrui
mingrui / pre-commit
Created Jul 5, 2018
pre commit hook for git secret
View pre-commit
#!/bin/sh
echo "# git secret hide!"
exec git secret hide
View gpu-server-config.md

total: 64000 cny

config:
gtx 1080 ti * 4
server motherboard with dual cpu slot * 1
cpu * 2
ram 128gb * 1
hhd 10tb * 1
server case * 1
power supply * 1

View test_dice.py
# source: https://github.com/shreyaspadhy/UNet-Zoo
def test(train_accuracy=False, save_output=False):
test_loss = 0
correct = 0
if train_accuracy:
loader = train_loader
else:
loader = test_loader
View dice_loss_compare.py
class DICELossMultiClass(nn.Module):
def __init__(self):
super(DICELossMultiClass, self).__init__()
def forward(self, output, mask):
probs = output[:, 1, :, :]
mask = torch.squeeze(mask, 1)
@mingrui
mingrui / gist:187f0e629007443268ce8c1414012ed5
Created Apr 29, 2018
docker-ce : Depends: libseccomp2 (>= 2.3.0) but 2.2.3-3ubuntu3 is to be installed
View gist:187f0e629007443268ce8c1414012ed5
When installing latest docker-ec 18, I encountered libseccomp2 version problem
https://www.ubuntuupdates.org/ppa/ubuntu_sdk_release?dist=xenial
add this to update libseccomp2
then install docker-ce
You can’t perform that action at this time.