wsdp 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wsdp-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yuanhao Cui
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
wsdp-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.4
2
+ Name: wsdp
3
+ Version: 0.0.1
4
+ Summary: A pipeline for large scale deep-learning based wireless sensing tasks, including preprocess, training and eval
5
+ Author-email: sdp <ochiruhana@outlook.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Yuanhao Cui
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/yuanhao-cui/Sensing-Data-Protocol
29
+ Project-URL: Bug Tracker, https://github.com/yuanhao-cui/Sensing-Data-Protocol/issues
30
+ Requires-Python: >=3.11
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: torch>=2.7.1
34
+ Requires-Dist: numpy>=2.4.1
35
+ Requires-Dist: matplotlib>=3.10.0
36
+ Requires-Dist: scikit_learn==1.8.0
37
+ Requires-Dist: seaborn==0.13.2
38
+ Dynamic: license-file
39
+
40
+ [![SDP](https://img.shields.io/badge/Sensing_Dataset-Platform-356596)](https://sdp8.org/)
41
+ ![TOML](https://img.shields.io/badge/dynamic/toml?url=https://raw.githubusercontent.com/yuanhao-cui/Sensing-Data-Protocol/refs/heads/main/pyproject.toml&query=%24.project.name&logo=pypi&label=pip
42
+ )
43
+ [![GitHub](https://img.shields.io/github/license/yuanhao-cui/Sensing-Data-Protocol?color=green
44
+ )](https://github.com/yuanhao-cui/Sensing-Data-Protocol/blob/main/LICENSE)
45
+ ![Welcome to Ask](https://img.shields.io/badge/Welcome_to-Ask-72B063)
46
+
47
+ # SDP: Sensing Data-Protocol for Scalable Wireless Sensing
48
+
49
+ **SDP (Sensing Data-Protocol)** is a protocol-level abstraction framework and unified benchmark for scalable wireless sensing and perception based on wireless signals such as Channel State Information(CSI).
50
+ The protocol is designed to decouple learning performance from hardware-specific artifacts, enabling **fair, reproducible, and scalable evaluation** of deep learning models for wireless sensing tasks.
51
+
52
+ SDP enforces **deterministic physical-layer sanitization, canonical tensor construction, and standardized training and evaluation procedures**, making it particularly suitable for wireless sensing research, activity recognition, device-free sensing, and cross-dataset benchmarking.
53
+
54
+ Our main result can be illustrated by the following pictures.
55
+
56
+ **Mean Top-1 accuracy with 95% confidence intervals over five runs**
57
+ ![accuracy](./img/accuracy.png)
58
+
59
+ **Performance stability comparison between the baseline and SDP across five random seeds. Boxplots show the distribution of Top-1 accuracy, with scattered dots indicating individual runs.**
60
+ ![accuracy](./img/reproducibility_and_stability.png)
61
+
62
+ **Rank consistency heatmap across five random seeds on the ElderAL-CSI dataset. Colors indicate per-seed performance rank (1 = best), with overlaid Top-1 accuracy values. Full SDP exhibits stable top-ranked performance, while ablated variants show higher ranking variability.**
63
+ ![accuracy](./img/ablation_rank.png)
64
+
65
+ More details are illustrated in our paper [A Sensing Dataset Protocol for Benchmarking and Multi-Task Wireless Sensing](https://arxiv.org/abs/2512.12180).
66
+
67
+ ```
68
+ @misc{huang2025sensingdatasetprotocolbenchmarking,
69
+ title={A Sensing Dataset Protocol for Benchmarking and Multi-Task Wireless Sensing},
70
+ author={Jiawei Huang and Di Zhang and Yuanhao Cui and Xiaowen Cao and Tony Xiao Han and Xiaojun Jing and Christos Masouros},
71
+ year={2025},
72
+ eprint={2512.12180},
73
+ archivePrefix={arXiv},
74
+ primaryClass={eess.SP},
75
+ url={https://arxiv.org/abs/2512.12180},
76
+ }
77
+ ```
78
+
79
+ ---
80
+
81
+ ## 🔍 Why SDP?
82
+
83
+ Wireless sensing research often suffers from:
84
+ - Inconsistent **hardware configurations**
85
+ - Dataset-specific **preprocessing pipelines**
86
+ - Non-reproducible **training and evaluation protocols**
87
+
88
+ **SDP addresses these challenges at the protocol level**, rather than the model level.
89
+ The SDP unified data processing pipeline, including sanitation and transformation, transform raw data into uniform canonical tensors ready for deep learning.
90
+ ![pipeline](./img/pipeline.png)
91
+ ### Core Design Principles
92
+ - **Protocol-level abstraction**
93
+ - **Deterministic PHY-layer sanitization** to eliminate randomness
94
+ - **Canonical tensor representation** for deep learning compatibility
95
+ - **Unified benchmark pipeline** across datasets and tasks
96
+ - **Extensible architecture** for new datasets, processors, and models
97
+
98
+ ---
99
+
100
+ ## 📦 Key Features
101
+
102
+ - **Unified CSI abstraction** across heterogeneous datasets
103
+ - **Hardware-agnostic signal representation**
104
+ - **Modular reader–processor–model pipeline**
105
+ - **Deterministic preprocessing for reproducibility**
106
+ - **Plug-and-play extensibility**
107
+ - **Benchmark-ready training and evaluation flow**
108
+
109
+ ---
110
+
111
+ ## 📚 Target Use Cases
112
+
113
+ ### SDP is optimized for:
114
+ - CSI-based **Human Activity Recognition (HAR)**
115
+ - **Gait recognition** and biometric identification
116
+ - **Wireless sensing + deep learning** research
117
+ - **Cross-domain / cross-hardware generalization**
118
+ - **scalable sensing systems**
119
+
120
+ Typical downstream models include CNNs, Transformers, BiLSTMs, GNNs, and hybrid architectures.
121
+
122
+ ### Supported Dataset:
123
+
124
+ **Widar3.0**
125
+ - Dataset Link: [Widar3.0: Wi-Fi-based Hand Gesture Recognition Dataset](http://sdp8.org/Dataset?id=028828f9-1997-48df-895c-9724551a22ae)
126
+ - CSI Shape: (Time, 30, 1, 3)
127
+ - num of classes: 6
128
+ - total num of used samples: 12,000
129
+
130
+ **GaitID**
131
+ - Dataset Link: [GaitID: Wi-Fi-based Human Gait Recognition Dataset](http://sdp8.org/Dataset?id=87a65da2-18cb-4b8f-a1ec-c9696890172b)
132
+ - CSI Shape: (Time, 30, 1, 3)
133
+ - num of classes: 11
134
+ - total num of used samples: 22,500
135
+
136
+ **XRF55**
137
+ - Dataset Link: [XRF55: A Radio Frequency Dataset for Human Indoor Action Analysis](http://sdp8.org/Dataset?id=705e08e7-637e-49a1-aff1-b2f9644467ae)
138
+ - CSI Shape: (270, 1000)
139
+ - num of classes: 55
140
+ - total num of used samples: 9,900
141
+
142
+ **ElderAL-CSI**
143
+ - Dataset Link: [ElderAL-CSI](http://sdp8.org/Dataset?id=f144678d-5b4a-4bb9-902c-7aff4916a029)
144
+ - CSI Shape: (Time, 512, 3, 3)
145
+ - num of classes: 6
146
+ - total num of used samples: 2,400
147
+
148
+
149
+ ---
150
+
151
+ ## 📁 Project Structure Overview
152
+
153
+ ### `algorithms/`
154
+
155
+ Store various functions for implementing different signal processing algorithms.
156
+
157
+ - `./denoising.py`
158
+ Store functions for signal denoising
159
+ - `./phase_calibration.py`
160
+ Store functions for phase calibration
161
+
162
+ ---
163
+
164
+ ### `readers/`
165
+ - Store Dataset-specific readers
166
+ - Converts raw files into `List` of `CSIData`
167
+
168
+ ---
169
+
170
+ ### `structure/`
171
+ - Definition of `CSIData` and all kinds of `CSIFrame`
172
+
173
+ ---
174
+
175
+ ### `processors/`
176
+ - Definition of processor for signal processing and sanitization
177
+
178
+ ---
179
+
180
+ ### `datasets/`
181
+ - Definition of classes extend `torch.utils.data.Dataset`
182
+
183
+ ---
184
+
185
+ ### `models/`
186
+ - Definition of deep learning models
187
+
188
+ ---
189
+
190
+
191
+
192
+ ## 🚀 Quick Start
193
+
194
+ ### Install Dependencies
195
+ Create a venv for dependencies, then run:
196
+ ```bash
197
+ pip install sdp
198
+ ```
199
+
200
+ ### Download Data
201
+ Please download needed datasets from [Our SDP Website](http://sdp8.org/) or:
202
+ ```bash
203
+ sdp xxxx [dataset_name] [dir] # TBD
204
+ ```
205
+ After downloading, please organize **elderAL** datasets in the structure below for extracting labels:
206
+ ```
207
+ ├── data
208
+ ├── elderAL
209
+ │ ├── action0_static_new
210
+ │ ├── action1_walk_new
211
+ │ ├── ...
212
+
213
+ ├── widar
214
+ ├── gait
215
+ ├── xrf55
216
+ ```
217
+
218
+ ### Run
219
+ This project supports both functional call and command-line call in the shell. The calling methods are as follows respectively:
220
+
221
+ ---
222
+ - For `input_path`: please use `data/[widar, gait, xrf55, elderAL]`
223
+ - For `dataset_name`: `widar`, `gait`, `xrf55`, `elderAL` are available
224
+ ---
225
+
226
+ **function call:**
227
+ ```pycon
228
+ from sdp import pipeline
229
+
230
+ pipeline(input_path, output_folder, dataset_name)
231
+ ```
232
+
233
+ Considering that training process will generate numerous lines about info like acc and loss, so in function-call, it is recommended to run in this way:
234
+ ```bash
235
+ nohup python script.py >> output.log 2>&1 &
236
+ ```
237
+
238
+ **command:**
239
+ ```bash
240
+ sdp run [input_path] [output_folder] [dataset_name]
241
+ ```
wsdp-0.0.1/README.md ADDED
@@ -0,0 +1,202 @@
1
+ [![SDP](https://img.shields.io/badge/Sensing_Dataset-Platform-356596)](https://sdp8.org/)
2
+ ![TOML](https://img.shields.io/badge/dynamic/toml?url=https://raw.githubusercontent.com/yuanhao-cui/Sensing-Data-Protocol/refs/heads/main/pyproject.toml&query=%24.project.name&logo=pypi&label=pip
3
+ )
4
+ [![GitHub](https://img.shields.io/github/license/yuanhao-cui/Sensing-Data-Protocol?color=green
5
+ )](https://github.com/yuanhao-cui/Sensing-Data-Protocol/blob/main/LICENSE)
6
+ ![Welcome to Ask](https://img.shields.io/badge/Welcome_to-Ask-72B063)
7
+
8
+ # SDP: Sensing Data-Protocol for Scalable Wireless Sensing
9
+
10
+ **SDP (Sensing Data-Protocol)** is a protocol-level abstraction framework and unified benchmark for scalable wireless sensing and perception based on wireless signals such as Channel State Information(CSI).
11
+ The protocol is designed to decouple learning performance from hardware-specific artifacts, enabling **fair, reproducible, and scalable evaluation** of deep learning models for wireless sensing tasks.
12
+
13
+ SDP enforces **deterministic physical-layer sanitization, canonical tensor construction, and standardized training and evaluation procedures**, making it particularly suitable for wireless sensing research, activity recognition, device-free sensing, and cross-dataset benchmarking.
14
+
15
+ Our main result can be illustrated by the following pictures.
16
+
17
+ **Mean Top-1 accuracy with 95% confidence intervals over five runs**
18
+ ![accuracy](./img/accuracy.png)
19
+
20
+ **Performance stability comparison between the baseline and SDP across five random seeds. Boxplots show the distribution of Top-1 accuracy, with scattered dots indicating individual runs.**
21
+ ![accuracy](./img/reproducibility_and_stability.png)
22
+
23
+ **Rank consistency heatmap across five random seeds on the ElderAL-CSI dataset. Colors indicate per-seed performance rank (1 = best), with overlaid Top-1 accuracy values. Full SDP exhibits stable top-ranked performance, while ablated variants show higher ranking variability.**
24
+ ![accuracy](./img/ablation_rank.png)
25
+
26
+ More details are illustrated in our paper [A Sensing Dataset Protocol for Benchmarking and Multi-Task Wireless Sensing](https://arxiv.org/abs/2512.12180).
27
+
28
+ ```
29
+ @misc{huang2025sensingdatasetprotocolbenchmarking,
30
+ title={A Sensing Dataset Protocol for Benchmarking and Multi-Task Wireless Sensing},
31
+ author={Jiawei Huang and Di Zhang and Yuanhao Cui and Xiaowen Cao and Tony Xiao Han and Xiaojun Jing and Christos Masouros},
32
+ year={2025},
33
+ eprint={2512.12180},
34
+ archivePrefix={arXiv},
35
+ primaryClass={eess.SP},
36
+ url={https://arxiv.org/abs/2512.12180},
37
+ }
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 🔍 Why SDP?
43
+
44
+ Wireless sensing research often suffers from:
45
+ - Inconsistent **hardware configurations**
46
+ - Dataset-specific **preprocessing pipelines**
47
+ - Non-reproducible **training and evaluation protocols**
48
+
49
+ **SDP addresses these challenges at the protocol level**, rather than the model level.
50
+ The SDP unified data processing pipeline, including sanitation and transformation, transform raw data into uniform canonical tensors ready for deep learning.
51
+ ![pipeline](./img/pipeline.png)
52
+ ### Core Design Principles
53
+ - **Protocol-level abstraction**
54
+ - **Deterministic PHY-layer sanitization** to eliminate randomness
55
+ - **Canonical tensor representation** for deep learning compatibility
56
+ - **Unified benchmark pipeline** across datasets and tasks
57
+ - **Extensible architecture** for new datasets, processors, and models
58
+
59
+ ---
60
+
61
+ ## 📦 Key Features
62
+
63
+ - **Unified CSI abstraction** across heterogeneous datasets
64
+ - **Hardware-agnostic signal representation**
65
+ - **Modular reader–processor–model pipeline**
66
+ - **Deterministic preprocessing for reproducibility**
67
+ - **Plug-and-play extensibility**
68
+ - **Benchmark-ready training and evaluation flow**
69
+
70
+ ---
71
+
72
+ ## 📚 Target Use Cases
73
+
74
+ ### SDP is optimized for:
75
+ - CSI-based **Human Activity Recognition (HAR)**
76
+ - **Gait recognition** and biometric identification
77
+ - **Wireless sensing + deep learning** research
78
+ - **Cross-domain / cross-hardware generalization**
79
+ - **scalable sensing systems**
80
+
81
+ Typical downstream models include CNNs, Transformers, BiLSTMs, GNNs, and hybrid architectures.
82
+
83
+ ### Supported Dataset:
84
+
85
+ **Widar3.0**
86
+ - Dataset Link: [Widar3.0: Wi-Fi-based Hand Gesture Recognition Dataset](http://sdp8.org/Dataset?id=028828f9-1997-48df-895c-9724551a22ae)
87
+ - CSI Shape: (Time, 30, 1, 3)
88
+ - num of classes: 6
89
+ - total num of used samples: 12,000
90
+
91
+ **GaitID**
92
+ - Dataset Link: [GaitID: Wi-Fi-based Human Gait Recognition Dataset](http://sdp8.org/Dataset?id=87a65da2-18cb-4b8f-a1ec-c9696890172b)
93
+ - CSI Shape: (Time, 30, 1, 3)
94
+ - num of classes: 11
95
+ - total num of used samples: 22,500
96
+
97
+ **XRF55**
98
+ - Dataset Link: [XRF55: A Radio Frequency Dataset for Human Indoor Action Analysis](http://sdp8.org/Dataset?id=705e08e7-637e-49a1-aff1-b2f9644467ae)
99
+ - CSI Shape: (270, 1000)
100
+ - num of classes: 55
101
+ - total num of used samples: 9,900
102
+
103
+ **ElderAL-CSI**
104
+ - Dataset Link: [ElderAL-CSI](http://sdp8.org/Dataset?id=f144678d-5b4a-4bb9-902c-7aff4916a029)
105
+ - CSI Shape: (Time, 512, 3, 3)
106
+ - num of classes: 6
107
+ - total num of used samples: 2,400
108
+
109
+
110
+ ---
111
+
112
+ ## 📁 Project Structure Overview
113
+
114
+ ### `algorithms/`
115
+
116
+ Store various functions for implementing different signal processing algorithms.
117
+
118
+ - `./denoising.py`
119
+ Store functions for signal denoising
120
+ - `./phase_calibration.py`
121
+ Store functions for phase calibration
122
+
123
+ ---
124
+
125
+ ### `readers/`
126
+ - Store Dataset-specific readers
127
+ - Converts raw files into `List` of `CSIData`
128
+
129
+ ---
130
+
131
+ ### `structure/`
132
+ - Definition of `CSIData` and all kinds of `CSIFrame`
133
+
134
+ ---
135
+
136
+ ### `processors/`
137
+ - Definition of processor for signal processing and sanitization
138
+
139
+ ---
140
+
141
+ ### `datasets/`
142
+ - Definition of classes extend `torch.utils.data.Dataset`
143
+
144
+ ---
145
+
146
+ ### `models/`
147
+ - Definition of deep learning models
148
+
149
+ ---
150
+
151
+
152
+
153
+ ## 🚀 Quick Start
154
+
155
+ ### Install Dependencies
156
+ Create a venv for dependencies, then run:
157
+ ```bash
158
+ pip install sdp
159
+ ```
160
+
161
+ ### Download Data
162
+ Please download needed datasets from [Our SDP Website](http://sdp8.org/) or:
163
+ ```bash
164
+ sdp xxxx [dataset_name] [dir] # TBD
165
+ ```
166
+ After downloading, please organize **elderAL** datasets in the structure below for extracting labels:
167
+ ```
168
+ ├── data
169
+ ├── elderAL
170
+ │ ├── action0_static_new
171
+ │ ├── action1_walk_new
172
+ │ ├── ...
173
+
174
+ ├── widar
175
+ ├── gait
176
+ ├── xrf55
177
+ ```
178
+
179
+ ### Run
180
+ This project supports both functional call and command-line call in the shell. The calling methods are as follows respectively:
181
+
182
+ ---
183
+ - For `input_path`: please use `data/[widar, gait, xrf55, elderAL]`
184
+ - For `dataset_name`: `widar`, `gait`, `xrf55`, `elderAL` are available
185
+ ---
186
+
187
+ **function call:**
188
+ ```pycon
189
+ from sdp import pipeline
190
+
191
+ pipeline(input_path, output_folder, dataset_name)
192
+ ```
193
+
194
+ Considering that training process will generate numerous lines about info like acc and loss, so in function-call, it is recommended to run in this way:
195
+ ```bash
196
+ nohup python script.py >> output.log 2>&1 &
197
+ ```
198
+
199
+ **command:**
200
+ ```bash
201
+ sdp run [input_path] [output_folder] [dataset_name]
202
+ ```
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "wsdp"
7
+ version = "0.0.1"
8
+ description = "A pipeline for large scale deep-learning based wireless sensing tasks, including preprocess, training and eval"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {file = "LICENSE"}
12
+
13
+ authors = [
14
+ {name = "sdp", email = "ochiruhana@outlook.com"},
15
+ ]
16
+
17
+ dependencies = [
18
+ "torch>=2.7.1",
19
+ "numpy>=2.4.1",
20
+ "matplotlib>=3.10.0",
21
+ "scikit_learn==1.8.0",
22
+ "seaborn==0.13.2",
23
+ ]
24
+
25
+ [project.urls]
26
+ "Homepage" = "https://github.com/yuanhao-cui/Sensing-Data-Protocol"
27
+ "Bug Tracker" = "https://github.com/yuanhao-cui/Sensing-Data-Protocol/issues"
28
+
29
+ [project.scripts]
30
+ sdp = "sdp.cli:main_cli"
@@ -0,0 +1 @@
1
+ from .core import pipeline
@@ -0,0 +1,2 @@
1
+ from .denoising import wavelet_denoise_csi
2
+ from .phase_calibration import phase_calibration
@@ -0,0 +1,59 @@
1
+ import pywt
2
+ import numpy as np
3
+
4
+
5
+ def wavelet_denoise_csi(csi_tensor):
6
+ """
7
+ :param: csi_tensor (np.ndarray): CSI data
8
+ """
9
+ # split amplitutde and phase
10
+ amplitude = np.abs(csi_tensor)
11
+ phase = np.angle(csi_tensor)
12
+
13
+ denoised_amplitude = np.copy(amplitude)
14
+
15
+ T, S, R = csi_tensor.shape
16
+
17
+ def _denoise_channel(channel):
18
+ try:
19
+ # in case of dividing zero
20
+ if np.std(channel) < 1e-6:
21
+ return channel
22
+ L = len(channel)
23
+
24
+ w_name = 'db4'
25
+ wavelet = pywt.Wavelet(w_name)
26
+ max_level = pywt.dwt_max_level(L, wavelet.dec_len)
27
+
28
+ if max_level < 1:
29
+ w_name = 'db1'
30
+ wavelet = pywt.Wavelet(w_name)
31
+ max_level = pywt.dwt_max_level(L, wavelet.dec_len)
32
+
33
+ if max_level < 1:
34
+ return channel
35
+
36
+ level = min(2, max_level)
37
+ coeffs = pywt.wavedec(channel, wavelet, level=level)
38
+
39
+ # calculate threshold of noise (VisuShrink)
40
+ sigma = np.median(np.abs(coeffs[-1])) / 0.6745
41
+ threshold = sigma * np.sqrt(2 * np.log(L))
42
+
43
+ denoised_coeffs = [coeffs[0]] + [np.sign(c) * np.maximum(np.abs(c) - threshold, 0) for c in coeffs[1:]]
44
+
45
+ # refactor
46
+ denoised_signal = pywt.waverec(denoised_coeffs, wavelet)
47
+
48
+ return denoised_signal[:L]
49
+ except Exception as e:
50
+ print(f"wavalet denoising fail: {e}. original signal will be returned.")
51
+ return channel
52
+
53
+ for rx in range(R):
54
+ for sc in range(S):
55
+ denoised_amplitude[:, sc, rx] = _denoise_channel(amplitude[:, sc, rx])
56
+
57
+ denoised_csi_tensor = denoised_amplitude * np.exp(1j * phase)
58
+
59
+ return denoised_csi_tensor
@@ -0,0 +1,26 @@
1
+ import numpy as np
2
+
3
+
4
+ def phase_calibration(csi_data):
5
+ """
6
+ param:
7
+ csi_data: 3D CSI data with shape of [Timestamp, Frequency, Antenna]
8
+ """
9
+ T, F, A = csi_data.shape
10
+ csi_phase_corrected = np.zeros_like(csi_data, dtype=complex)
11
+ sub_carrier_indices = np.arange(F)
12
+
13
+ # tackle data of every single timestamp and antenna
14
+ for t in range(T):
15
+ for a in range(A):
16
+ csi_packet = csi_data[t, :, a]
17
+ raw_phase = np.angle(csi_packet)
18
+ unwrapped_phase = np.unwrap(raw_phase)
19
+ p = np.polyfit(sub_carrier_indices, unwrapped_phase, 1)
20
+
21
+ phase_error = np.polyval(p, sub_carrier_indices)
22
+ correction_term = np.exp(-1j * phase_error)
23
+ csi_phase_corrected[t, :, a] = csi_packet * correction_term
24
+
25
+ return csi_phase_corrected
26
+
wsdp-0.0.1/sdp/cli.py ADDED
@@ -0,0 +1,25 @@
1
+ import argparse
2
+
3
+ from core import pipeline
4
+
5
+
6
+ def _run_pipeline(args):
7
+ pipeline(input_path=args.input_path, output_folder=args.output_folder, dataset=args.dataset)
8
+
9
+
10
+ def main_cli():
11
+ parser = argparse.ArgumentParser(description="sdp CLI")
12
+ subparser = parser.add_subparsers(dest="command", required=True, help="available commands")
13
+
14
+ parser_run = subparser.add_parser("run", help="run pipeline")
15
+ parser_run.add_argument("input_path", type=str, help="input data path")
16
+ parser_run.add_argument("output_folder", type=str, help="output path")
17
+ parser_run.add_argument("dataset", type=str, help="dataset name")
18
+ parser_run.set_defaults(func=_run_pipeline)
19
+
20
+ args = parser.parse_args()
21
+
22
+ if hasattr(args, 'func'):
23
+ args.func(args)
24
+ else:
25
+ parser.print_help()
File without changes