{"id":19439592,"url":"https://github.com/hypox64/candock","last_synced_at":"2025-04-24T22:32:43.477Z","repository":{"id":40959785,"uuid":"177591192","full_name":"HypoX64/candock","owner":"HypoX64","description":"A time series signal analysis and classification framework","archived":false,"fork":false,"pushed_at":"2023-07-06T22:12:04.000Z","size":1461,"stargazers_count":85,"open_issues_count":6,"forks_count":29,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T12:46:50.872Z","etag":null,"topics":["classification","data-augmentation","data-preprocessing","deep-learning","eeg","series-signal-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HypoX64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-03-25T13:23:50.000Z","updated_at":"2025-02-27T02:53:41.000Z","dependencies_parsed_at":"2022-09-05T16:21:22.005Z","dependency_job_id":"73d8b49c-2e69-47da-a228-a511282c0969","html_url":"https://github.com/HypoX64/candock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HypoX64%2Fcandock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HypoX64%2Fcandock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HypoX64%2Fcandock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HypoX64%2Fcandock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HypoX64","download_url":"https://codeload.github.com/HypoX64/candock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250719839,"owners_count":21476145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classification","data-augmentation","data-preprocessing","deep-learning","eeg","series-signal-analysis"],"created_at":"2024-11-10T15:25:09.049Z","updated_at":"2025-04-24T22:32:43.136Z","avatar_url":"https://github.com/HypoX64.png","language":"Python","readme":"\u003cdiv align=\"center\"\u003e    \n\u003cimg src=\"./imgs/compare.png \" alt=\"image\" style=\"zoom:100%;\" /\u003e\n\u003c/div\u003e\n\n# candock\n\n| English | [中文版](./README_CN.md) |\u003cbr\u003e\u003cbr\u003e\nA time series signal analysis and classification framework.\u003cbr\u003e\nIt contain multiple network  and provide data preprocessing, data augmentation, training, evaluation, testing and other functions.\u003cbr\u003e\nSome output examples: [heatmap](./image/heatmap_eg.png)  [running_loss](./image/running_loss_eg.png)  [log.txt](./docs/log_eg.txt)\u003cbr\u003e\n\n## Feature\n### Data preprocessing\n* Normliaze  :   5_95 | maxmin | None\n* Filter           :   fft | fir | iir | wavelet | None\n\n### Data augmentation\nVarious data augmentation method.\u003cbr\u003e[[Time Series Data Augmentation for Deep Learning: A Survey]](https://arxiv.org/pdf/2002.12478.pdf)\n* Base     :  scale, warp, app, aaft, iaaft, filp, crop\n* Noise   :  spike, step, slope, white, pink, blue, brown, violet\n* Gan      :  dcgan\n\n### Network\nVarious networks for evaluation.\n\u003e1d\n\u003e\n\u003e\u003elstm, cnn_1d, resnet18_1d, resnet34_1d, multi_scale_resnet_1d, micro_multi_scale_resnet_1d,autoencoder,mlp\n\n\u003e2d(stft spectrum)\n\u003e\n\u003e\u003emobilenet, resnet18, resnet50, resnet101, densenet121, densenet201, squeezenet, dfcnn, multi_scale_resnet,\n\n### K-fold\nUse k-fold to make the results more reliable.\n```--k_fold```\u0026```--fold_index```\u003cbr\u003e\n\n* --k_fold\n```python\n# fold_num of k-fold. If 0 or 1, no k-fold and cut 80% to train and other to eval.\n```\n* --fold_index\n```python\n\"\"\"--fold_index\nWhen --k_fold != 0 or 1:\nCut dataset into sub-set using index , and then run k-fold with sub-set\nIf input 'auto', it will shuffle dataset and then cut dataset equally\nIf input: [2,4,6,7]\nwhen len(dataset) == 10\nsub-set: dataset[0:2],dataset[2:4],dataset[4:6],dataset[6:7],dataset[7:]\n-------\nWhen --k_fold == 0 or 1:\nIf input 'auto', it will shuffle dataset and then cut 80% dataset to train and other to eval\nIf input: [5]\nwhen len(dataset) == 10\ntrain-set : dataset[0:5]  eval-set : dataset[5:]\n\"\"\"\n```\n\n## A example: Use EEG to classify sleep stage\n[sleep-edfx](https://github.com/HypoX64/candock/tree/f24cc44933f494d2235b3bf965a04cde5e6a1ae9)\u003cbr\u003e\nThank [@swalltail99](https://github.com/swalltail99)for the bug. In other to load sleep-edfx dataset，please install mne==0.18.0\u003cbr\u003e\n```bash\npip install mne==0.18.0\n```\n\n## Getting Started\n### Prerequisites\n- Linux, Windows,mac\n- CPU or NVIDIA GPU + CUDA CuDNN\n- Python 3\n- Pytroch 1.0+\n### Dependencies\nThis code depends on torchvision, numpy, scipy, PyWavelets, matplotlib, tensorboardX， available via pip install.\u003cbr\u003e\n```bash\npip install -r requirements.txt\n```\n### Clone this repo:\n```bash\ngit clone https://github.com/HypoX64/candock\ncd candock\n```\n### Download dataset and pretrained-model\n[[Google Drive]](https://drive.google.com/open?id=1NTtLmT02jqlc81lhtzQ7GlPK8epuHfU5)   [[百度云,y4ks]](https://pan.baidu.com/s/1WKWZL91SekrSlhOoEC1bQA)\n\n* This datasets consists of signals.npy(shape:18207, 1, 2000) and labels.npy(shape:18207) which can be loaded by \"np.load()\".\n* samples:18207,  channel:1,  length of each sample:2000,  class:50\n* Top1 err: 2.09%\n### Train\n* Begin training\n```bash\npython3 train.py --label 50 --input_nc 1 --dataset_dir ./datasets/simple_test --save_dir ./checkpoints/simple_test --model_name micro_multi_scale_resnet_1d --gpu_id 0 --batchsize 64 --k_fold 5\n# if you want to use cpu to train, please input --gpu_id -1\n```\n* Run \"tensorboardx\" to see outputs.\n```bash\ntensorboard --logdir checkpoints/tensorboardX --host=[your server's IP]\n```\n* Open \"http://[your server's IP]:6006\" on browser\n* More [options](./util/options.py).\n### Test\n```bash\npython3 simple_test.py --label 50 --input_nc 1 --model_name micro_multi_scale_resnet_1d --gpu_id 0\n# if you want to use cpu to test, please input --gpu_id -1\n```\n\n## Training with your own dataset\n* step1: Generate signals.npy and labels.npy in the following format.\n```python\n#1.type:numpydata   signals:np.float32   labels:np.int64\n#2.shape  signals:[num,ch,length]    labels:[num]\n#num:samples_num, ch :channel_num,  length:length of each sample\n#for example:\nsignals = np.zeros((10,1,10),dtype='np.float64')\nlabels = np.array([0,0,0,0,0,1,1,1,1,1])      #0-\u003eclass0    1-\u003eclass1\n```\n* step2: input  ```--dataset_dir \"your_dataset_dir\"``` when running code.\n\n### [ More training options](./util/options.py).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypox64%2Fcandock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypox64%2Fcandock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypox64%2Fcandock/lists"}