Skip to content

Instantly share code, notes, and snippets.

View OmarAlkousa's full-sized avatar
👻

Omar Alkousa OmarAlkousa

👻
View GitHub Profile
@OmarAlkousa
OmarAlkousa / Signal_Generator_class.py
Last active February 29, 2024 04:41
Building a class to generate sinusoidal signals
# Import the required package
import numpy as np
# Building a class Signal for better use.
class Signal:
"""
Generate sinusoidal signals with specific ampltiudes, frequencies, duration,
sampling rate, and phase.
Example:
@OmarAlkousa
OmarAlkousa / scipy_ecg_signal.py
Last active January 25, 2023 12:19
Built-in Electrocardiogram signal using scipy package
# Import the required packages
from scipy.misc import electrocardiogram
import matplotlib.pyplot as plt
# Built-in ECG signal
ecg = electrocardiogram()
# Plot the results
plt.plot(ecg)
plt.xlim(0, 1000)
@OmarAlkousa
OmarAlkousa / generate_random_signal.py
Last active January 25, 2023 11:44
This gist is to represent how to generate a simple random signal using numpy package and plot the results using matplotlib.
# Import the required packages
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-poster')
%matplotlib inline
# Generate a random signal with length 10
random_signal = np.random.rand(100)
@OmarAlkousa
OmarAlkousa / genereate_sine_signals.py
Created January 25, 2023 11:17
This gist is to represent how to generate a simple sine wave using numpy package and plot the results using matplotlib.
# Import the required packages
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-poster')
%matplotlib inline
# Generate a vector with 200 sample from 0 to 20
x = np.linspace(0,20,200)
# Generate the sine wave of x variables
@OmarAlkousa
OmarAlkousa / dicom2csv.py
Last active January 14, 2023 10:14
This GitHub gist is for converting DICOM metadata into CSV file. You can see the DICOM dataset on Kaggle following the link: https://www.kaggle.com/datasets/dmisky/dlwptvolumetricdicomlung
# Implement the required package
# If you don't have PyDicom, uncomment the next line of code
# !pip install pydicom
import pydicom
import pandas as pd
import glob
def dicom2csv(extract = [],
move_on = [(0x7FE0,0x0008), (0x7FE0,0x0009), (0x7FE0,0x0010)],
folder_path = str(),
@OmarAlkousa
OmarAlkousa / elements_method.py
Created December 31, 2022 15:25
These GitHub gists are meant to explain the output of the .elements() method of DataSet class from PyDicom Package. This is a follow-up gist for the previous gist in the following link https://gist.github.com/OmarAlkousa/53b35934cd3fac3d381f0448b8e27073. You can see the DICOM dataset on Kaggle following the link: https://www.kaggle.com/datasets/…
# Extract the top-level elements of the Dataset Class
[*dcm_data.elements()]
@OmarAlkousa
OmarAlkousa / dcm_read_output.py
Last active December 31, 2022 15:22
These GitHub gists are meant to explain the output of the dcmread() function from PyDicom Package. You can see the DICOM dataset on Kaggle following the link: https://www.kaggle.com/datasets/dmisky/dlwptvolumetricdicomlung
# Install and import the package
!pip install pydicom
import pydicom
# Reading a DICOM file from a specific path
dcm_data = pydicom.dcmread('/content/drive/MyDrive/Datasets/Kaggle/DICOM/dicom_lung/000000.dcm')
dcm_data