Skip to content

Instantly share code, notes, and snippets.

@Nico-Curti
Nico-Curti / read_nifti_opencv.cpp
Last active May 25, 2021 15:55
Read .nii file into OpenCV. In this way the nifti slices are stored into a vector of cv :: Mat easy to use (PAY ATTENTION to update the switch dtype according to your needs)
//g++ read_nifti.cpp -O3 -std=c++17 `pkg-config opencv --cflags --libs` -o read_nifti
#include <iostream>
#include <fstream>
#include <vector>
#include <opencv2/opencv.hpp>
#include <memory>
template < typename dtype >
@miykael
miykael / motion_correction_of_temporal_high_resolution_fMRI_bandpass.ipynb
Last active June 26, 2021 14:49
Motion correction of fMRI data with high temporal resolution (~500ms), using a band-pass filter
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@artkpv
artkpv / union_find.py
Last active February 15, 2021 12:03
Union-Find in Python (weighted, path compression, connected components)
class UnionFind:
"""Weighted quick-union with path compression and connected components.
The original Java implementation is introduced at
https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf
>>> uf = UnionFind(10)
>>> for (p, q) in [(3, 4), (4, 9), (8, 0), (2, 3), (5, 6), (5, 9),
... (7, 3), (4, 8), (6, 1)]:
... uf.union(p, q)