Skip to content

Instantly share code, notes, and snippets.

View RyanZurrin's full-sized avatar
💭
Trying my best , failure is not an option for me.

Ryan Zurrin RyanZurrin

💭
Trying my best , failure is not an option for me.
View GitHub Profile
@RyanZurrin
RyanZurrin / disable_update_instructions.md
Created February 22, 2024 20:49
CentOS 9, disable auto updates

The updating comes from a package manager that is automatically enabled. To stop from updating you need to stop the service with the following:

systemctl stop packagekit.service

@RyanZurrin
RyanZurrin / build_measures_csv.py
Last active February 2, 2024 18:28
consolidate the tract measures from multiple csv files into a single source for easier anaylisis
import os
import pandas as pd
import argparse
from tqdm import tqdm
def read_cluster_mapping(cluster_mapping_file, hemisphere_code):
"""Read cluster mapping file and return clusters for the specified hemisphere code ('l', 'r', 'c')."""
cluster_df = pd.read_csv(cluster_mapping_file)
relevant_clusters = cluster_df[cluster_df['Location_Label'] == hemisphere_code]['Cluster_Index'].tolist()
return relevant_clusters
@RyanZurrin
RyanZurrin / extract_dicom_metadata.py
Last active March 6, 2024 19:04
extract specified metadata from DICOM files
#!/usr/bin/env python3
import os
import csv
import argparse
import re
from tqdm import tqdm
from pydicom.filereader import dcmread
from pydicom.errors import InvalidDicomError
from pydicom.datadict import dictionary_keyword
@RyanZurrin
RyanZurrin / rebuild_icon_cache.bat
Created January 18, 2024 19:24
Rebuild Windows icon cache
@echo off
SETLOCAL
echo This script will attempt to fix your icon cache.
echo Please save all work as your Windows Explorer will be restarted.
echo Press any key to continue...
pause > nul
echo.
echo Killing Explorer process...
@RyanZurrin
RyanZurrin / dice_calculator.py
Last active May 16, 2025 09:49
A Python scipt for calculating the dice scores
#!/usr/bin/env python3
import numpy
import nibabel
import argparse
def calculate_dice_coefficients(file1, file2):
input1_nii = nibabel.load(file1)
input2_nii = nibabel.load(file2)
@RyanZurrin
RyanZurrin / process_transformations.py
Created November 21, 2023 16:03
A python script that uses an ANTS function, antsApplyTransforms on multliple volumes files for multiple subjects
#!/usr/bin/env python3
import os
import subprocess
import argparse
from tqdm import tqdm
from multiprocessing import Pool
def format_filename(filename):
"""
@RyanZurrin
RyanZurrin / process_wm_data.py
Created November 21, 2023 15:59
A Python script for that uses wm_tract_to_volume, available at https://github.com/SlicerDMRI/whitematteranalysis for processing multiple tract files from multiple subjects in a very specific format. This is not a generic scipt but can be easily modified. into nii volumes.
#!/usr/bin/env python3
import os
import subprocess
import argparse
import shlex
from multiprocessing import Pool
def process_file(args):
@RyanZurrin
RyanZurrin / chimera_setup_v2.md
Last active November 21, 2023 16:00
quick and easy to follow guide to set up chimera env
  1. connect to chimera
  • 2 hop from umb unix: ssh -tt username@users3.cs.umb.edu ssh -tt username@chimera.umb.edu

  • 2 hop from lab machine (gonzo, gargoyle, vampire) ssh -tt username@lab_computer.verymad.net ssh -tt username@chimera.umb.edu

  • 1 hop from lab machine: ssh -tt username@chimera.umb.edu

@RyanZurrin
RyanZurrin / create_softlinks.sh
Created September 7, 2023 13:21
DWI Softlink Creator A bash script to automate the creation of soft links for DWI (Diffusion Weighted Imaging) files within a nested directory structure. Designed to target files with specific naming patterns and session data. Supports error handling and checks to avoid duplicate link creation.
@RyanZurrin
RyanZurrin / replace_substrings.py
Created September 7, 2023 13:18
# Filename Substring Replacer A Python script designed to target and replace specific substrings within filenames across specified directories. Ideal for deep directory structures where consistent filename changes are needed. Features: - Uses `glob` to match directory patterns and locate files. - Accepts user-specified arguments with `argparse` …
import os
import glob
import argparse
from tqdm import tqdm
def rename_files_in_dir(target_dir, search_str, replace_str):
renamed_files = []
# Use glob to get all filenames that contain the specified search string
filenames = glob.glob(f"{target_dir}/*{search_str}*")