Skip to content

Instantly share code, notes, and snippets.

View satra's full-sized avatar

Satrajit Ghosh satra

View GitHub Profile
@satra
satra / add_asset_to_dandiset.py
Last active September 13, 2023 03:03
Add an existing asset to a new dandiset
from dandi.dandiapi import DandiAPIClient
from dandischema.models import Resource, RelationType
from getpass import getpass
import pandas as pd
import json
token = getpass() # Enter dandi api token when prompted
df = pd.read_csv("dandi_assets_l1.csv")
@satra
satra / encode-biosample.json
Created September 27, 2022 00:32
encode biosample schema 26+
{
"title": "Biosample",
"description": "Schema for submitting a biosample.",
"comment": "For cultured samples this object represents unique growths or culture harvests.",
"id": "/profiles/biosample.json",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"required": [
"award",
"lab",
@satra
satra / nifti2ngff.py
Created May 9, 2022 11:22
Convert Nifti to NGFF
import math
import numpy as np
import nibabel as nb
import zarr
from numcodecs import Blosc
from ome_zarr.writer import write_multiscale
from skimage.transform import pyramid_gaussian
img = nb.load("sub-S01_T2w.nii.gz")
data = img.get_fdata()
@satra
satra / rechunk_ngff.py
Created February 12, 2022 21:08
rechunk an ngff file
from numcodecs import Blosc
import numpy as np
from pathlib import Path
from rechunker import rechunk
import sys
from tempfile import TemporaryDirectory
import zarr
import click
from pydra.mark import task, annotate
import pydra as pyd
@satra
satra / fastio.py
Last active March 7, 2022 20:16 — forked from jart/fastio.py
Multithreaded Python os.walk
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@satra
satra / dandiselenium.py
Created May 1, 2021 20:10
Login to DANDI Web UI using selenium
from selenium import webdriver
import chromedriver_binary
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from getpass import getpass
class DANDILogin:
@satra
satra / keybase.md
Created March 7, 2021 16:46
keybase

Keybase proof

I hereby claim:

  • I am satra on github.
  • I am satra (https://keybase.io/satra) on keybase.
  • I have a public key ASC3FGdm7lQWwCvetJcZKdApiR72oyZejsl2pPw-xKODyQo

To claim this, I am signing this object:

@satra
satra / generate_dockerfile.sh
Created May 19, 2018 20:06
Apply ANTs Jointfusion using Mindboggle atlases
docker run -it --rm kaczmarj/neurodocker:master generate docker \
--base neurodebian:stretch \
--pkg-manager apt \
--install graphviz tree git-annex-standalone vim \
emacs-nox nano less ncdu tig sed build-essential \
libsm-dev libx11-dev libxt-dev libxext-dev libglu1-mesa \
--freesurfer version=6.0.0-min \
--ants version=b43df4bfc8 method=source cmake_opts='-DBUILD_SHARED_LIBS=ON' make_opts='-j 4'\
--run 'ln -s /usr/lib/x86_64-linux-gnu /usr/lib64' \
--miniconda \
@satra
satra / customwinnow.py
Last active May 10, 2017 19:52
Feature selection based on constructed noise feature
import sklearn
from sklearn.base import BaseEstimator
from sklearn.base import TransformerMixin
class CustFsNoiseWinnow(BaseEstimator, TransformerMixin):
"""Remove features with less importance than a noise feature"""
import scipy
import scipy.stats
import numpy as np
Verifying that +satrajit is my blockchain ID. https://onename.com/satrajit